洛谷P1042題目連結https://www.luogu.org/problemnew/show/P1042
阿新 • • 發佈:2018-11-07
#include <iostream> #include <stdio.h> #include <string.h> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <math.h> #include <bitset> #include <algorithm> #include <climits> using namespace std; #define lson 2*i #define rson 2*i+1 #define Pair pair<int, int> #define ULL unsigned long long #define LS l,mid,lson #define RS mid+1,r,rson #define up(i,x,y) for(int i=x;i<y;i++) #define down(i,x,y) for(int i=x;i>=y;i--) #define MEM(a,x) memset(a,x,sizeof(a)) #define W(a) while(a) #define gcd(a,b) __gcd(a,b) #define LL long long #define N 150005 #define MOD 1000000007 #define INF 0x3f3f3f3f #define EXP 1e-8 #define lowbit(x) (x&-x) #define _ ios_base::sync_with_stdio(0),cin.tie(0) //freopen("1.txt", "r", stdin); #include <iostream> #include <stdio.h> #include <string.h> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <math.h> #include <bitset> #include <algorithm> #include <climits> using namespace std; #define lson 2*i #define rson 2*i+1 #define Pair pair<int, int> #define ULL unsigned long long #define LS l,mid,lson #define RS mid+1,r,rson #define up(i,x,y) for(int i=x;i<y;i++) #define down(i,x,y) for(int i=x;i>=y;i--) #define MEM(a,x) memset(a,x,sizeof(a)) #define W(a) while(a) #define gcd(a,b) __gcd(a,b) #define LL long long #define N 150005 #define MOD 1000000007 #define INF 0x3f3f3f3f #define EXP 1e-8 #define lowbit(x) (x&-x) #define _ ios_base::sync_with_stdio(0),cin.tie(0) //freopen("1.txt", "r", stdin); string s; int main(){ int a=0,b=0,c=0; getline(cin,s,'E');//獲取s,直到遇到'E' for(int i=0;i<s.size();i++){ //if if(s[i]=='W') a++; if(s[i]=='L') b++; if(s[i]=='E') break; if((a>=11||b>=11)&&abs(a-b)>=2){//如果if放到for下面第一句開頭會90分,可能出現11進位制11:0 0:0而21進位制就進行一場22:0,大家可以想一下 cout<<a<<":"<<b<<endl; a=0; b=0; } } cout<<a<<":"<<b<<endl<<endl; a=0,b=0; for(int i=0;i<s.size();i++){ if(s[i]=='W') a++; if(s[i]=='L') b++; if(s[i]=='E') break; if((a>=21||b>=21)&&abs(a-b)>=2){ cout<<a<<":"<<b<<endl; a=0; b=0; } } cout<<a<<":"<<b<<endl; }