Tranvick

Untitled

Jan 9th, 2012
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <cstdio>
  2. long long n,k,ans;
  3.  
  4. long long lcm(long long x,long long y){
  5.     long long a=x,b=y;
  6.     while (a && b){
  7.         if (a>b) a%=b;
  8.         else b%=a;
  9.     }
  10.     a+=b;
  11.     return (x/a)*y;
  12. }
  13.  
  14. int main(){
  15.     freopen("input.txt","r",stdin);
  16.     freopen("output.txt","w",stdout);
  17.     scanf("%I64d%I64d",&n,&k);
  18.     for (long long g=1;g*g<=k;g++)
  19.         if (k%g==0){
  20.             if (lcm(k,(n/k)*g)==n) ++ans;
  21.             if (g*g!=k && lcm(k,n/g)==n) ++ans;
  22.         }
  23.     printf("%I64d",ans);
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment