題目連結:http://codeforces.com/contest/1104/problem/A
第一題:
#include<bits/stdc++.h>
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair<ll,ll>
#define mk(x,y) make_pair(x,y)
const int maxn =1e5+10;
const int mod=998244353;
int inf;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int n;
int main()
{
cin>>n;
cout<<n<<endl;
rep(i,0,n) cout<<1<<" ";
return 0;
}
第二題:
#include<bits/stdc++.h>
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair<ll,ll>
#define mk(x,y) make_pair(x,y)
const int maxn =1e5+10;
const int mod=998244353;
int inf;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
string s;
char tmp[maxn];
int cnt=0,ans=0;
int main()
{
cin>>s;int len=s.size();
tmp[cnt++]=s[0];
rep(i,1,len){
if(s[i]==tmp[cnt-1]) cnt--,ans++;
else tmp[cnt++]=s[i];
}
if(ans&1) puts("Yes");
else puts("No");
return 0;
}
第三題:
#include<bits/stdc++.h>
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair<ll,ll>
#define mk(x,y) make_pair(x,y)
const int maxn =1e4+10;
const int mod=998244353;
int inf;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
string s;
int cnt0=0,cnt1=0;
int main(){
cin>>s;
int len=s.size();
rep(i,0,len){
if(s[i]=='0') {
cnt0++;
if(cnt0&1) cout<<"1 4"<<endl;
else cout<<"3 4"<<endl;
}
else{
cnt1++;
if(cnt1&1) cout<<"4 1"<<endl;
else cout<<"4 3"<<endl;
}
}
return 0;
}///011000110101