題單地址:https://ac.nowcoder.com/acm/contest/19304?from=acdiscuss
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int a,b; cin>>a>>b;
if(a>b) puts(">");
else if(a==b) puts("=");
else puts("<");
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int n; cin>>n;
if(n%2!=0) cout<<n*3+1;
else cout<<n/2;
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int a,b; cin>>a>>b;
if(a==b) puts("Tacit!");
else puts("No Tacit!");
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int a,b; cin>>a>>b;
if(a%b==0) puts("YES");
else puts("NO");
return 0;
}
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
unordered_map<LL,int>mp;
LL a,b;
int main(void)
{
cin>>a>>b;
for(int i=1;i<=b/i;i++)
{
if(b%i==0)
{
mp[i]++;
mp[b/i]++;
}
}
if(mp.count(a)!=0) cout<<a+b;
else cout<<b-a;
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
long long int n; cin>>n;
if(n%2==0&&n>2) puts("YES, you can divide the watermelon into two even parts.");
else puts("NO, you can't divide the watermelon into two even parts.");
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int n; cin>>n;
n--;
if(n%2==0) cout<<n+1;
else cout<<-1<<endl;
return 0;
}
多餘的話,來回踱步即可。
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int x,y,n; cin>>x>>y>>n;
int step=n-x-y;
if(step>=0&&step%2==0) puts("YES");
else puts("NO");
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int n; cin>>n;
if(n>50&&n%2==0) cout<<"yes";
else cout<<"no";
return 0;
}
#include<bits/stdc++.h>
using namespace std;
bool check(int n)
{
if(n%400==0||(n%4==0&&n%100!=0)) return true;
return false;
}
int main(void)
{
int n; cin>>n;
if(check(n)) puts("yes");
else puts("no");
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int x,cnt1,cnt2;
int main(void)
{
for(int i=0;i<10;i++)
{
int x; cin>>x;
if(x<0) cnt1++;
else cnt2++;
}
printf("positive:%d\n",cnt2);
printf("negative:%d",cnt1);
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
double a,b,c; cin>>a>>b>>c;
double sum=(a+b+c)/3;
if(sum>=60) puts("NO");
else puts("YES");
return 0;
}
#include<stdio.h>
int main(void)
{
int a,b,c;
int max,min;
scanf("%d %d %d",&a,&b,&c);
max=a>b?a:b;
max=max>c?max:c;
min=a<b?a:b;
min=min<c?min:c;
printf("The maximum number is : %d\n",max);
printf("The minimum number is : %d",min);
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int a[3];
int ans[15];
int main(void)
{
for(int i=0;i<3;i++) cin>>a[i];
ans[0]=a[0]+a[1]+a[2];
ans[1]=a[0]*a[1]*a[2];
ans[2]=(a[0]+a[1])*a[2];
ans[3]=a[0]+a[1]*a[2];
ans[4]=a[0]*a[1]+a[2];
ans[5]=a[0]*(a[1]+a[2]);
sort(ans,ans+6);
printf("%d\n",ans[5]);
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int a[15]={0,4,4,1,1,1,2,2,2,3,3,3,4};
int main(void)
{
string s; cin>>s;
int t=stoi(s.substr(4));
if(a[t]==1) puts("spring");
else if(a[t]==2) puts("summer");
else if(a[t]==3) puts("autumn");
else if(a[t]==4) puts("winter");
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int a,b,c;
scanf("%d/%d/%d",&a,&b,&c);
if(b<10||(b==10&&c<29)) puts("No. It's not too late.");
else puts("QAQ");
return 0;
}
暴力模擬日期。
#include<bits/stdc++.h>
using namespace std;
int month[15]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int a,b,c,y,m,d;
bool f(int x)
{
if(x%400==0||(x%4==0&&x%100!=0)) return true;
return false;
}
bool check(int s1,int s2,int s3)
{
for(int i=1;i<=2;i++)
{
s3++;
if(f(s1)) month[2]=29;
if(s3>month[s2]) s2++,s3=1;
if(s2>=13) s2=1,s1++;
month[2]=28;
}
if(s1==a&&s2==b&&s3==c) return true;
return false;
}
int main(void)
{
scanf("%d-%d-%d",&a,&b,&c);
y=2000,m=1,d=1;
while(!check(y,m,d))
{
d++;
if(f(y)) month[2]=29;
if(d>month[m]) m++,d=1;
if(m>=13) m=1,y++;
month[2]=28;
}
printf("%d-%02d-%02d",y,m,d);
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int n; cin>>n;
printf("%g",n*12*2.54*10);
return 0;
}
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n; cin>>n;
if(n%2==0) cout<<n/2;
else cout<<(n+1)/2<<endl;
}
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int n,a,b; cin>>n>>a>>b;
int cnt=0;
for(int i=0;i<n;i++)
{
if(i>=a&&(n-i-1)<=b) cnt++;
}
cout<<cnt;
}
https://ac.nowcoder.com/acm/contest/19304/U
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n; cin>>n;
int ans1=ceil(n*0.10)-(int)(n*0.1);
int ans2=ans1+ceil(n*0.20)-(int)(n*0.2);//多少個變金就有都少個變銀+多餘的變銀的
int ans3=ans2+ceil(n*0.30)-(int)(n*0.3);
cout<<ans1<<" "<<ans2<<" "<<ans3;
}
#include<bits/stdc++.h>
using namespace std;
int cnt,maxv,d;
int main(void)
{
for(int i=0;i<7;i++)
{
int a,b; cin>>a>>b;
if(a+b>8)
{
cnt++;
if(a+b>maxv) maxv=a+b,d=i+1;
}
}
if(!cnt) cout<<0<<endl;
else cout<<d;
}
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
string s; cin>>s;
int sum=0,k=1;
for(int i=0;i<s.size()-1;i++)
{
if(s[i]>='0'&&s[i]<='9')
{
sum+=(s[i]-'0')*k;
k++;
}
}
sum=sum%11;
if( (sum==10&&s[s.size()-1]=='X')||sum==(s[s.size()-1]-'0')) puts("Right");
else
{
if(sum!=10) s[s.size()-1]='0'+sum;
else s[s.size()-1]='X';
cout<<s;
}
}