Algorithm/BOJ

백준 1075번 C++

poopooreum 2023. 7. 21. 15:34
반응형

https://www.acmicpc.net/problem/1075

1075번: 나누기

첫째 줄에 N, 둘째 줄에 F가 주어진다. N은 100보다 크거나 같고, 2,000,000,000보다 작거나 같은 자연수이다. F는 100보다 작거나 같은 자연수이다.

www.acmicpc.net


정답 코드

#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n,f;
    cin>>n>>f;
    int r=n%100;
    n=n-r;
    for(int i=0;i<100;i++)
    {
        if(n%f==0)break;
        n+=1;
    }
    int res=n%100;
    if(res/10==0)printf("0");
    printf("%d",res);
    return 0;
}


반응형