游客 Signup | Login
中文 | En

2989 - 循环练习14

有一个六位数,第一位是1,如果把它移到个位,新的六位数正好是原数的三倍,求原来的六位数.    

Input

无输入

Output

一行一个数据

Examples

Input


                

Output


                

Solution C

#include <stdio.h>
#include <stdlib.h>
int main()
{
	int i;
    for(i=100000;i<=199999;i++)
    {
		if((i*3)==((i%100000)*10+i/100000)) printf("%d",i);
    
    }
	return 0;
}

Solution C++

#include <iostream>

using namespace std;

int main()
{
	int a,b,c,d,e;
	for(int a=1;a<=9;++a)
	for(int b=1;b<=9;++b)
	for(int c=1;c<=9;++c)
	for(int d=1;d<=9;++d)
	for(int e=1;e<=9;++e)
	{
		int ans=1*100000+a*10000+b*1000+c*100+d*10+e;
		int tmp=a*100000+b*10000+c*1000+d*100+e*10+1;
		if(tmp%ans==0&&tmp/ans==3)
		cout << ans << endl;
	}
	return 0;
}
Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题