Codeforeces Good Bye 2017 A-C
头实在是有点痛,做了两个就坚持不住了,躺了30分钟,脑袋里浑浑噩噩,什么都没有一片空白, 浑身发热。 这个夜晚睡得最难受的一晚了。
A
【题解】
奇数+元音
【代码实现】
int main() { string str; cin>>str; int ans=0; int len=str.length(); for(int i=0;i<len;i++) { if(str[i]=='a'||str[i]=='e'||str[i]=='o'||str[i]=='u'||str[i]=='i') { ans++; } else if(str[i]>='0'&&str[i]<='9') { if( (str[i]-'0') %2==1) { ans++; } } } cout<<ans<<endl; return 0; }
123
B
暴力模拟把, 直接。 4!=24种 最大24种 24种排列 模拟看看这个序列能不能到达
【代码实现】
#include <bits/stdc++.h> #include <iostream> #include <stdio.h> #include <algorithm> #include <cmath> #include <math.h> #include <cstring> #include <string> #include <queue> #include <deque> #include <stack> #include <stdlib.h> #include <list> #include <map> #include <set> #include <bitset> #include <vector> #define mem(a,b) memset(a,b,sizeof(a)) #define findx(x,b,n) lower_bound(b+1,b+1+n,x)-b #define FIN freopen("input.txt","r",stdin) #define FOUT freopen("output.txt","w",stdout) #define SHUT std::ios::sync_with_stdio(false) #define lson rt << 1, l, mid #define rson rt << 1|1, mid + 1, r #define FI(n) IO::read(n) #define Be IO::begin() using namespace std; typedef long long ll; const double PI=acos(-1); const int INF=0x3f3f3f3f; const double esp=1e-6; const int maxn=1e6+5; const int MAXN=50005; const int MOD=1e9+7; const int mod=1e9+7; int dir[5][2]={0,1,0,-1,1,0,-1,0}; namespace IO { const int MT = 5e7; char buf[MT]; int c,sz; void begin(){ c = 0; sz = fread(buf, 1, MT, stdin);//一次性输入 } template<class T> inline bool read(T &t){ while( c < sz && buf[c] != '-' && ( buf[c]<'0' || buf[c] >'9')) c++; if( c>=sz) return false; bool flag = 0; if( buf[c]== '-') flag = 1,c++; for( t=0; c<=sz && '0' <=buf[c] && buf[c] <= '9'; c++ ) t= t*10 + buf[c]-'0'; if(flag) t=-t; return true; } } ll inv[maxn*2]; inline void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){if(!b){ x=1; y=0; d=a; }else{ ex_gcd(b,a%b,d,y,x); y-=x*(a/b);};} inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a;} inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll ans=exgcd(b,a%b,x,y);ll temp=x;x=y;y=temp-a/b*y;return ans;} inline ll lcm(ll a,ll b){ return b/gcd(a,b)*a;} inline ll qpow(ll x,ll n){ll res=1;for(;n;n>>=1){if(n&1)res=(res*x)%MOD;x=(x*x)%MOD;}return res;} inline ll inv_exgcd(ll a,ll n){ll d,x,y;ex_gcd(a,n,d,x,y);return d==1?(x+n)%n:-1;} inline ll inv1(ll b){return b==1?1:(MOD-MOD/b)*inv1(MOD%b)%MOD;} inline ll inv2(ll b){return qpow(b,MOD-2);} int a[55][55]; // 1上 2 下 3 左 4 右 int s1,s2,e1,e2; int ans; int n,m; string abc; int main() { mem(a,0); cin>>n>>m; string str; ans=0; for(int i=0;i<n;i++) { cin>>str; for(int j=0;j<str.length();j++) { if(str[j]=='.') a[i][j]=1; else if(str[j]=='#') a[i][j]=2; else if(str[j]=='S') { s1=i,s2=j; //a[i][j]=1; } else if(str[j]=='E') { //a[i][j]=1; e1=i;e2=j; } } } //cout<<s1<<" "<<s2<<" "<<e1<<" "<<e2<<endl; cin>>abc; for(int x=1;x<=4;x++) { for(int y=1;y<=4;y++) { for(int z=1;z<=4;z++) { for(int d=1;d<=4;d++) { if(x!=y&&x!=z&&x!=d&&y!=z&&y!=d&&z!=d) { // cout<<x<<y<<z<<d<<endl; int i,j,c; for(i=s1,j=s2,c=0;c<abc.length();c++) { if(abc[c]=='0') { if(x==1)//shang i-=1; else if(x==2)//xia i+=1; else if(x==3)//zuo j-=1; else if(x==4)//you j+=1; } else if(abc[c]=='1') { if(y==1) i-=1; else if(y==2) i+=1; else if(y==3) j-=1; else if(y==4) j+=1; } else if(abc[c]=='2') { if(z==1) i-=1; else if(z==2) i+=1; else if(z==3) j-=1; else if(z==4) j+=1; } else if(abc[c]=='3') { if(d==1) i-=1; else if(d==2) i+=1; else if(d==3) j-=1; else if(d==4) j+=1; } if(a[i][j]==2) break; if(i<0||i>=n||j<0||j>=m) break; if(i==e1&&j==e2) { // cout<<x<<" "<<y<<" "<<z<<" "<<d<<endl; ans++; break; } } } } } } } cout<<ans<<endl; return 0; }
C
求每一个的圆的y坐标最大,能在碰到的基础上。
扫描每一个点之前的。 比较横坐标。
这个题卡 精度。
【代码实现】
cout 格式输出 20位 - - ios:base 关掉cout和cin的绑定提高速度。 设置输出格式
#include <bits/stdc++.h> #include <iostream> #include <string.h> #include <stdio.h> #define mem(a,b) memset(a,b,sizeof(a)) using namespace std; long double y[1200]; int n; long double x[1200]; long double r; int main() { ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20); cout.tie(nullptr); cin.tie(nullptr); mem(x,0); mem(y,0); cin>>n>>r; r=r*2; for(int i=0;i<n;i++) { cin>>x[i]; y[i]=r/2; for(int j=0;j<i;j++) { double dx=abs(x[i]-x[j]); if(dx<=r) y[i]=max(y[i],y[j]+ sqrt(r*r-dx*dx)); } cout<<y[i]<<" "; //printf("%.9LF ",y[i]); } cout<<endl; return 0; }
岂曰无衣?与子同袍。王于兴师,修我戈矛。与子同仇!
岂曰无衣?与子同泽。王于兴师,修我矛戟。与子偕作!
岂曰无衣?与子同裳。王于兴师,修我甲兵。与子偕行!