Codeforces Round #392 (Div. 2) 题解(待续)
来源:互联网 发布:微信 网络代理 编辑:程序博客网 时间:2024/05/06 18:24
A.Holiday Of Equality
#include<bits/stdc++.h>using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define Rep(i,n) for(int i=0;i<n;i++)#define ForD(i,n) for(int i=n;i;i--)#define ForkD(i,k,n) for(int i=n;i>=k;i--)#define RepD(i,n) for(int i=n;i>=0;i--)#define Forp(x) for(int p=Pre[x];p;p=Next[p])#define Forpiter(x) for(int &p=iter[x];p;p=Next[p]) #define Lson (o<<1)#define Rson ((o<<1)+1)#define MEM(a) memset(a,0,sizeof(a));#define MEMI(a) memset(a,127,sizeof(a));#define MEMi(a) memset(a,128,sizeof(a));#define INF (2139062143)#define F (1000000007)#define pb push_back#define mp make_pair #define fi first#define se second#define vi vector<int> #define pi pair<int,int>#define SI(a) ((a).size())#define Pr(kcase,ans) printf("Case #%d: %I64d\n",kcase,ans);#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;#define PRi2D(a,n,m) For(i,n) { \ For(j,m-1) cout<<a[i][j]<<' ';\ cout<<a[i][m]<<endl; \ } #pragma comment(linker, "/STACK:102400000,102400000")#define ALL(x) (x).begin(),(x).end()typedef long long ll;typedef long double ld;typedef unsigned long long ull;ll mul(ll a,ll b){return (a*b)%F;}ll add(ll a,ll b){return (a+b)%F;}ll sub(ll a,ll b){return ((a-b)%F+F)%F;}void upd(ll &a,ll b){a=(a%F+b%F)%F;}int read(){ int x=0,f=1; char ch=getchar(); while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();} while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();} return x*f;} int main(){ freopen("A.in","r",stdin);// freopen(".out","w",stdout); int n=read(); int c=0,p=0; For(i,n) { int t=read(); c+=t; p=max(p,t); } cout<<n*p-c<<endl; return 0;}
B.Blown Garland
#include<bits/stdc++.h>using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define Rep(i,n) for(int i=0;i<n;i++)#define ForD(i,n) for(int i=n;i;i--)#define ForkD(i,k,n) for(int i=n;i>=k;i--)#define RepD(i,n) for(int i=n;i>=0;i--)#define Forp(x) for(int p=Pre[x];p;p=Next[p])#define Forpiter(x) for(int &p=iter[x];p;p=Next[p]) #define Lson (o<<1)#define Rson ((o<<1)+1)#define MEM(a) memset(a,0,sizeof(a));#define MEMI(a) memset(a,127,sizeof(a));#define MEMi(a) memset(a,128,sizeof(a));#define INF (2139062143)#define F (1000000007)#define pb push_back#define mp make_pair #define fi first#define se second#define vi vector<int> #define pi pair<int,int>#define SI(a) ((a).size())#define Pr(kcase,ans) printf("Case #%d: %I64d\n",kcase,ans);#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;#define PRi2D(a,n,m) For(i,n) { \ For(j,m-1) cout<<a[i][j]<<' ';\ cout<<a[i][m]<<endl; \ } #pragma comment(linker, "/STACK:102400000,102400000")typedef long long ll;typedef long double ld;typedef unsigned long long ull;ll mul(ll a,ll b){return (a*b)%F;}ll add(ll a,ll b){return (a+b)%F;}ll sub(ll a,ll b){return ((a-b)%F+F)%F;}void upd(ll &a,ll b){a=(a%F+b%F)%F;}int read(){ int x=0,f=1; char ch=getchar(); while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();} while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();} return x*f;} map<char,int> h;int p[4];int main(){// freopen("B.in","r",stdin);// freopen(".out","w",stdout); string s; cin>>s; int n=s.length(); Rep(i,n) if (s[i]!='!') h[s[i]]=i%4; else p[i%4]++; cout<<p[h['R']]<<' '; cout<<p[h['B']]<<' '; cout<<p[h['Y']]<<' '; cout<<p[h['G']]<<endl; return 0;}
C.Unfair Poll
#include<bits/stdc++.h>using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define Rep(i,n) for(int i=0;i<n;i++)#define ForD(i,n) for(int i=n;i;i--)#define ForkD(i,k,n) for(int i=n;i>=k;i--)#define RepD(i,n) for(int i=n;i>=0;i--)#define Forp(x) for(int p=Pre[x];p;p=Next[p])#define Forpiter(x) for(int &p=iter[x];p;p=Next[p]) #define Lson (o<<1)#define Rson ((o<<1)+1)#define MEM(a) memset(a,0,sizeof(a));#define MEMI(a) memset(a,127,sizeof(a));#define MEMi(a) memset(a,128,sizeof(a));#define INF (2139062143)#define F (1000000007)#define pb push_back#define mp make_pair #define fi first#define se second#define vi vector<int> #define pi pair<int,int>#define SI(a) ((a).size())#define Pr(kcase,ans) printf("Case #%d: %I64d\n",kcase,ans);#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;#define PRi2D(a,n,m) For(i,n) { \ For(j,m-1) cout<<a[i][j]<<' ';\ cout<<a[i][m]<<endl; \ } #pragma comment(linker, "/STACK:102400000,102400000")#define ALL(x) (x).begin(),(x).end()typedef long long ll;typedef long double ld;typedef unsigned long long ull;ll mul(ll a,ll b){return (a*b)%F;}ll add(ll a,ll b){return (a+b)%F;}ll sub(ll a,ll b){return ((a-b)%F+F)%F;}void upd(ll &a,ll b){a=(a%F+b%F)%F;}int read(){ int x=0,f=1; char ch=getchar(); while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();} while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();} return x*f;} int main(){// freopen("C.in","r",stdin);// freopen(".out","w",stdout); ll n,m,k,x,y; cin>>n>>m>>k>>x>>y; if (n<=2) { ll mic=k/(n*m); k%=n*m; ll ans1=mic,ans2=mic; if (k) ++ans1; cout<<ans1<<' '<<ans2<<' '; ll ans3=mic; ll p=(x-1)*m+y; if (p<=k) ans3=ans1;else ans3=ans2; cout<<ans3<<endl; return 0; } ll mic=k/(m*(n-1)); ll mic1=(mic+1)/2,mic2=mic,mic3=mic/2; k%=(m*(n-1)); ll mic4=mic1,mic5=mic2,mic6=mic3; ll ans; if (x==1) ans=mic1;else if (x==n) ans=mic3;else ans=mic2; ll pos=(x-1)*m+y; if (mic%2==0) { if (k<m) ++mic4; else if(k==m) ++mic4,++mic1; else ++mic1,++mic5,++mic4; if (pos<=k) ++ans; } else { x=n-x+1; ll pos=(x-1)*m+y; if (pos<=k) ++ans; if (k<m) ++mic6; else if(k==m) ++mic6,++mic3; else ++mic3,++mic5,++mic6; } cout<<max(mic6,max(mic4,mic5))<<' '; cout<<min(mic1,min(mic2,mic3))<<' '; cout<<ans<<endl; return 0;}
D.Ability To Convert
#include<bits/stdc++.h>using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define Rep(i,n) for(int i=0;i<n;i++)#define ForD(i,n) for(int i=n;i;i--)#define ForkD(i,k,n) for(int i=n;i>=k;i--)#define RepD(i,n) for(int i=n;i>=0;i--)#define Forp(x) for(int p=Pre[x];p;p=Next[p])#define Forpiter(x) for(int &p=iter[x];p;p=Next[p]) #define Lson (o<<1)#define Rson ((o<<1)+1)#define MEM(a) memset(a,0,sizeof(a));#define MEMI(a) memset(a,127,sizeof(a));#define MEMi(a) memset(a,128,sizeof(a));#define INF (2139062143)#define F (1000000007)#define pb push_back#define mp make_pair #define fi first#define se second#define vi vector<int> #define pi pair<int,int>#define SI(a) ((a).size())#define Pr(kcase,ans) printf("Case #%d: %I64d\n",kcase,ans);#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;#define PRi2D(a,n,m) For(i,n) { \ For(j,m-1) cout<<a[i][j]<<' ';\ cout<<a[i][m]<<endl; \ } #pragma comment(linker, "/STACK:102400000,102400000")#define ALL(x) (x).begin(),(x).end()typedef long long ll;typedef long double ld;typedef unsigned long long ull;ll mul(ll a,ll b){return (a*b)%F;}ll add(ll a,ll b){return (a+b)%F;}ll sub(ll a,ll b){return ((a-b)%F+F)%F;}void upd(ll &a,ll b){a=(a%F+b%F)%F;}int read(){ int x=0,f=1; char ch=getchar(); while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();} while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();} return x*f;} char s[1000];ll gener(int i,int j) { if (i==j) return s[i]-'0'; if (s[i]=='0') return -1; ll p=0; Fork(k,i,j) { p=p*10; p+=s[k]-'0'; } return p;}int main(){ freopen("D.in","r",stdin);// freopen(".out","w",stdout); ll k=read(); cin>>s; int n=strlen(s); return 0; ll ans=0,c=0,m=1,p=1; RepD(i,n-1) { if (s[i]=='0') { int j=i; } ll c2=c+m*(s[i]-'0'); if (c2<k) { c=c2; m*=10; } else { ans+=p*c; p*=k; c=s[i]-'0',m=10; } } if (c) ans+=p*c; cout<<ans<<endl; return 0;}
E.Broken Tree
//waitng for updated
F.Geometrical Progression
如果我们枚举首项和某项,很容易判断,但是
不妨考虑枚举
#include<bits/stdc++.h>using namespace std;#define For(i,n) for(int i=1;i<=n;i++)#define Fork(i,k,n) for(int i=k;i<=n;i++)#define Rep(i,n) for(int i=0;i<n;i++)#define ForD(i,n) for(int i=n;i;i--)#define ForkD(i,k,n) for(int i=n;i>=k;i--)#define RepD(i,n) for(int i=n;i>=0;i--)#define Forp(x) for(int p=Pre[x];p;p=Next[p])#define Forpiter(x) for(int &p=iter[x];p;p=Next[p]) #define Lson (o<<1)#define Rson ((o<<1)+1)#define MEM(a) memset(a,0,sizeof(a));#define MEMI(a) memset(a,127,sizeof(a));#define MEMi(a) memset(a,128,sizeof(a));#define INF (2139062143)#define F (1000000007)#define pb push_back#define mp make_pair #define fi first#define se second#define vi vector<int> #define pi pair<int,int>#define SI(a) ((a).size())#define Pr(kcase,ans) printf("Case #%d: %I64d\n",kcase,ans);#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;#define PRi2D(a,n,m) For(i,n) { \ For(j,m-1) cout<<a[i][j]<<' ';\ cout<<a[i][m]<<endl; \ } #pragma comment(linker, "/STACK:102400000,102400000")#define ALL(x) (x).begin(),(x).end()typedef long long ll;typedef long double ld;typedef unsigned long long ull;ll mul(ll a,ll b){return (a*b)%F;}ll add(ll a,ll b){return (a+b)%F;}ll sub(ll a,ll b){return ((a-b)%F+F)%F;}void upd(ll &a,ll b){a=(a%F+b%F)%F;}int read(){ int x=0,f=1; char ch=getchar(); while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();} while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();} return x*f;} ll gcd(ll a,ll b){ if (!b) return a;return gcd(b,a%b);}#define MAXN (9000001)ll a[MAXN];int main(){// freopen("F.in","r",stdin);// freopen(".out","w",stdout); ll n,l,r; cin>>n>>l>>r; ll len=r-l+1; if (n==1) cout<<len; else if (n==2) cout<<len*(len-1); else if (n-1>log2(1e7)) cout<<'0'; else { ll ans=0; long double c=pow(r,1.0/(n-1.0)); c+=1e-5; for(ll i=1;i<=c;i++) { ll p=1; For(j,n-1) p*=i; a[i]=p; } For(i,c) For(j,i-1) if (gcd(i,j)==1) {// cout<<a[i]<<'/'<<a[j]<<endl; ll l1=l/a[j]; if (l%a[j]) ++l1; ll r1=r/a[i]; if (l1<=r1){ ans+=r1-l1+1;// cout<<l1<<' '<<r1<<endl; } } cout<<ans*2; } cout<<endl; return 0;}
0 0
- Codeforces Round #392 (Div. 2) 题解(待续)
- Codeforces Round #398 (Div. 2) 题解(待续)
- Codeforces Round #401 (Div. 2) 题解 (待续)
- Codeforces Round #404 (Div. 2) 题解(待续)
- Codeforces Round #360 (Div. 1) 题解(待续)
- Codeforces Round #362 (Div. 1) 题解(待续)
- Codeforces Round #363 (Div. 1) 题解(待续)
- Codeforces Round #364 (Div. 1) 题解(待续)
- Codeforces Round #411 (Div. 1) 题解 (待续)
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) 题解(待续)
- Codeforces Round #392 (Div. 2) 题解
- Codeforces Round #402 (Div. 1) 题解(待续)
- Codeforces Round #331 (Div. 2)【未完待续】
- 【codeforces】Codeforces Round #276 (Div. 2) 题解
- 【codeforces】Codeforces Round #277 (Div. 2) 题解
- 【codeforces】Codeforces Round #279 (Div. 2) 题解
- 【codeforces】Codeforces Round #283 (Div. 2) 【题解】
- 【codeforces】Codeforces Round #291 (Div. 2) 题解
- 5555555555555555
- 使用@WebServlet配置loadOnStartup的时候不起作用的解决方法
- 2017.再出发
- Command and Query Responsibility分离模式
- pep8 要求归纳
- Codeforces Round #392 (Div. 2) 题解(待续)
- 架設Jenkins伺服器自動建置Android apk檔
- android 学习笔记15-项目实战 切换显示动画 底部线条移动
- 访问电脑本地服务器
- BZOJ 4589(Hard Nim-FWT测试)
- 【Solr】Tomcat部署Solr5
- Struts2-动态调用action中的方法
- 使用Axis2方式发布webService的三种方式
- 数论 make them equal!