https://codeforces.com/contest/1525/problem/A
Problem - A - Codeforces
codeforces.com
[난이도] Div.2
[유형] 수학
[풀이]
K와 100-K의 최대공약수를 구한 뒤 100을 최대공약수로 나눠주면 된다.
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
using namespace std;
using ll = long long;
int t,k;
int gcd(int a,int b){
if(a>b) swap(a,b);
while(a>0){
int c = b%a;
b=a;
a=c;
}
return b;
}
int main(){
scanf("%d",&t);
while(t--){
scanf("%d",&k);
if(k==100){
puts("1");
continue;
}
int a = k;
int b = 100-k;
int g = gcd(a,b);
printf("%d\n",a/g+b/g);
}
}
https://github.com/has2/Problem-Solving/blob/master/codeforces/RoundEDU109-Div.2/A.cpp
'Problem-Solving > Codeforces' 카테고리의 다른 글
[Codeforces][Round #731][Div.3] A : Shortest Path with Obstacle (C++) (0) | 2021.07.18 |
---|---|
[Codeforces][Round #EDU109][Div.2] B : Permutation Sort (C++) (0) | 2021.05.18 |
[Codeforces][Round #702][Div.3] C : Sum of Cubes (C++) (0) | 2021.03.01 |
[Codeforces][Round #702][Div.3] B : Balanced Remainder (C++) (0) | 2021.03.01 |
[Codeforces][Round #702][Div.3] A : Dense Array (0) | 2021.03.01 |