#define inf 0x7fffffff#define ll long long//#define llu unsigned l_do you know ">
赞
踩
Mynavi Programming Contest 2021(AtCoder Beginner Contest 201)
#pragma GCC optimize(2) #pragma GCC optimize(3,"Ofast","inline") #include <bits/stdc++.h> #define inf 0x7fffffff #define ll long long //#define llu unsigned long long //#define int long long //#define int __int128 //#define double long double //#define double long long #define re register int //#define void inline void #define eps 1e-8 //#define mod 1e9+7 #define ls(p) p<<1 #define rs(p) p<<1|1 #define pi acos(-1.0) #define pb push_back #define mk make_pair #define P pair < int , int > using namespace std; const int mod=1e9+7; const int M=1e8; const int N=5e5+5;//??????.???? 4e8 int a[N]; void solve() { cin>>a[1]>>a[2]>>a[3]; sort(a+1,a+3+1); if(a[1]+a[3]==2*a[2]) puts("Yes"); else puts("No"); } signed main() { int T=1; // cin>>T; for(int index=1;index<=T;index++) { solve(); // puts(""); } return 0; } /* 5 10 -1 -5 -3 5 -1 1 */
#pragma GCC optimize(2) #pragma GCC optimize(3,"Ofast","inline") #include <bits/stdc++.h> #define inf 0x7fffffff #define ll long long //#define llu unsigned long long //#define int long long //#define int __int128 //#define double long double //#define double long long #define re register int //#define void inline void #define eps 1e-8 //#define mod 1e9+7 #define ls(p) p<<1 #define rs(p) p<<1|1 #define pi acos(-1.0) #define pb push_back #define mk make_pair #define P pair < int , int > using namespace std; const int mod=1e9+7; const int M=1e8; const int N=5e5+5;//??????.???? 4e8 struct node { int x; string s; }e[N]; int n; bool cmp(node i,node j) { if(i.x!=j.x) return i.x>j.x; return i.s<j.s; } void solve() { cin>>n; for(re i=1;i<=n;i++) cin>>e[i].s>>e[i].x; sort(e+1,e+n+1,cmp); cout<<e[2].s; } signed main() { int T=1; // cin>>T; for(int index=1;index<=T;index++) { solve(); // puts(""); } return 0; } /* 5 10 -1 -5 -3 5 -1 1 */
这大概是最恶心的一道题了,公式推了无数次,WA了又WA
#pragma GCC optimize(2) #pragma GCC optimize(3,"Ofast","inline") #include <bits/stdc++.h> #define inf 0x7fffffff #define ll long long //#define llu unsigned long long //#define int long long //#define int __int128 //#define double long double //#define double long long #define re register int //#define void inline void #define eps 1e-8 //#define mod 1e9+7 #define ls(p) p<<1 #define rs(p) p<<1|1 #define pi acos(-1.0) #define pb push_back #define mk make_pair #define P pair < int , int > using namespace std; const int mod=1e9+7; const int M=1e8; const int N=5e5+5;//??????.???? 4e8 char s[N]; int n,a1,a2,a3; int ans=1,cnt=1,ret; void solve() { for(re i=1;i<=4;i++) cnt*=i; scanf("%s",s+1); n=strlen(s+1); for(re i=1;i<=n;i++) if(s[i]=='o') a1++; else if(s[i]=='?') a3++; if(a1>4) { puts("0"); return; } if(a1==4) { cout<<cnt<<endl; return; } if(a1==0) { for(re i=1;i<=4;i++) ans*=a3; cout<<ans<<endl; return; } if(a1==1) { cout<<4*a3*a3*a3+6*a3*a3+4*a3+1<<endl; return; } if(a1==2) { // cout<<8+24*a3*a3+2*12*a3<<endl; cout<<14+12*a3*a3+24*a3<<endl; return; } if(a1==3) { ret+=36; ret+=24*a3; cout<<ret<<endl; return; } } signed main() { int T=1; // cin>>T; for(int index=1;index<=T;index++) { solve(); // puts(""); } return 0; } /* 5 10 -1 -5 -3 5 -1 1 */
好吧,最开始想了很久都没想到要反向推。
问:为什么取负,其实无所谓,主要是反向推取负便与思考。
#pragma GCC optimize(2) #pragma GCC optimize(3,"Ofast","inline") #include <bits/stdc++.h> #define inf 0x7fffffff #define ll long long //#define llu unsigned long long #define int long long //#define int __int128 //#define double long double //#define double long long #define re register int //#define void inline void #define eps 1e-8 //#define mod 1e9+7 #define ls(p) p<<1 #define rs(p) p<<1|1 #define pi acos(-1.0) #define pb push_back #define mk make_pair #define P pair < int , int > using namespace std; const int mod=1e9+7; const int M=1e8; const int N=2e3+5;//??????.???? 4e8 int f[N][N]; char s[N][N]; int n,m; void solve() { cin>>n>>m; for(re i=1;i<=n;i++) scanf("%s",s[i]+1); for(re i=n;i>=1;i--) for(re j=m;j>=1;j--) { if(i==n&&j==m) continue; int a1=-1e18,a2=-1e18; if(i!=n) { a1=-f[i+1][j]; if(s[i+1][j]=='+') a1++; else a1--; } if(j!=m) { a2=-f[i][j+1]; if(s[i][j+1]=='+') a2++; else a2--; } f[i][j]=max(a1,a2); } if(f[1][1]>0) puts("Takahashi"); else if(f[1][1]==0) puts("Draw"); else puts("Aoki"); } signed main() { int T=1; // cin>>T; for(int index=1;index<=T;index++) { solve(); // puts(""); } return 0; } /* 5 10 -1 -5 -3 5 -1 1 */
最先没想到怎么做,后来听朋友说,计算按位每一位的贡献。。。。
#pragma GCC optimize(2) #pragma GCC optimize(3,"Ofast","inline") #include <bits/stdc++.h> #define inf 0x7fffffff #define ll long long //#define llu unsigned long long #define int long long //#define int __int128 //#define double long double //#define double long long #define re register int //#define void inline void #define eps 1e-8 //#define mod 1e9+7 #define ls(p) p<<1 #define rs(p) p<<1|1 #define pi acos(-1.0) #define pb push_back #define mk make_pair #define P pair < int , int > using namespace std; const int mod=1e9+7; const int M=1e8; const int N=5e5+5;//??????.???? 4e8 int n; struct node { int ver,edge,next; }e[N]; int tot,head[N]; int d[N],f[N]; int ret=1,ans; void add(int x,int y,int z) { e[++tot].ver=y; e[tot].edge=z; e[tot].next=head[x]; head[x]=tot; } void addedge(int x,int y,int z) { add(x,y,z);add(y,x,z); } void dfs(int x,int pre) { for(re i=head[x];i;i=e[i].next) { int y=e[i].ver; int z=e[i].edge; if(y==pre) continue; d[y]=d[x]^z; dfs(y,x); } } void solve() { cin>>n; for(re i=1;i<n;i++) { int x,y,z; scanf("%lld%lld%lld",&x,&y,&z); addedge(x,y,z); } dfs(1,1); for(re i=0;i<=60;i++) { int cnt=0; for(re j=1;j<=n;j++) if((d[j]>>i)&1) cnt++; ans=(ans+(ret*cnt)%mod*(n-cnt))%mod; ret=(ret*2)%mod; } cout<<ans<<endl; } signed main() { int T=1; // cin>>T; for(int index=1;index<=T;index++) { solve(); // puts(""); } return 0; } /* 5 10 -1 -5 -3 5 -1 1 */
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。