Translate

Views

Tuesday, July 30, 2019

Solution Kattis · The Easiest Problem Is This One

https://open.kattis.com/problems/easiest
#include<bits/stdc++.h>
using namespace std;

int sum(int n){
 int s=0;
 while(n>0){
  s+=n%10;
  n/=10;
 }
 return s;
}

int main(){
 int n;
 while(cin>>n){ if (n==0) break;
  int i=11; 
  while(sum(i*n) != sum(n)){
   i++;  
  }
  cout<<i<<"\n";
 }
}
Good luck! If you need help please leave a comment :) 

No comments: