美文网首页
招银卡中心-公倍数-c++

招银卡中心-公倍数-c++

作者: Jacinth | 来源:发表于2017-09-13 21:10 被阅读0次

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <map>
    #include <string>
    #include <vector>
    #include <set>
    #include <queue>
    #include <deque>
    #include <stack>
    #include <algorithm>
    #include <unordered_map>
    using namespace std;
    /*解题思路:辗转相除法
    输入:1 1 10
    输出:10*/
    int main(){
        int a,b,n;
        while(cin>>a>>b>>n){
            int count=0;
            int t;
            int tmp;
            if((a>n)||(b>n)){
                count = 0;
            }
            else{
                t=n/a;
                for(int i=1;i<=t;i++){
                    tmp = a*i;
                    if(tmp%b==0){
                        count++;
                    }
                }
            }
            cout<<count<<endl;
        }
        system("pause");
        return 0;
    }
    

    相关文章

      网友评论

          本文标题:招银卡中心-公倍数-c++

          本文链接:https://www.haomeiwen.com/subject/frwlsxtx.html