https://codeforces.com/contest/1551/problem/A
Problem - A - Codeforces
codeforces.com
[난이도] Div.3
[유형] 수학
[풀이]
1) N%3==0
정확히 1:2로 나눠지므로
답은 c1: N/3 c2 : N/3
2) N%3==1
1 burle만 추가로 필요하므로
답은 c1: (N/3)+1 c2 : (N/3)
3) N%3==2
2 burle만 추가로 필요하므로
답은 c1: (N/3) c2 : (N/3)+1
#include <cstdio>
using namespace std;
int tc,n,a,b;
int main(){
scanf("%d",&tc);
while(tc--){
scanf("%d",&n);
int k = n/3;
int mod = n%3;
a=b=k;
if(mod==1){
a++;
}else if(mod==2){
b++;
}
printf("%d %d\n",a,b);
}
}
https://github.com/has2/Problem-Solving/blob/master/codeforces/Round734-Div.3/A.cpp
'Problem-Solving > Codeforces' 카테고리의 다른 글
[Codeforces][Round #734][Div.3] C : Interesting Story (C++) (0) | 2021.07.25 |
---|---|
[Codeforces][Round #734][Div.3] B-1 : Wonderful Coloring - 1 (C++) (0) | 2021.07.25 |
[Codeforces][Round #EDU111][Div.2] B : Maximum Cost Deletion (C++) (0) | 2021.07.18 |
[Codeforces][Round #EDU111][Div.2] A : Find The Array (C++) (0) | 2021.07.18 |
[Codeforces][Round #732][Div.2] B : AquaMoon and Stolen String (0) | 2021.07.18 |