NYOJ-34韩信点兵

来源:互联网 发布:手机测量长度软件 编辑:程序博客网 时间:2024/05/21 15:44
#include <iostream>#include <stdio.h>using namespace std;int a[5];int main(){    cin>>a[1]>>a[2]>>a[3];    int num=0;    int tep=1;    for(int i=1;i<=3;i++)    {        int temp;        if(i==1)            temp=3;        if(i==2)            temp=5;        if(i==3)            temp=7;        while(1)        {            if(num%temp==a[i])            {                tep*=temp;                break;            }            num+=tep;        }    }    if(num==0)        cout<<105<<endl;    else        cout<<num<<endl;    return 0;}

0 0