# 大哥们 帮个忙把 谢谢!

bigboy130 2004-04-30 06:29:38
Being given the positive integer 1 < K <= 10^4 you are to find a minimal positive integer N such that if you get the N's first (major) decimal digit away and append it to the end of the rest of N's decimal representation you will get an integer, which is K times less than N.

This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.

Input

The input consists of single line that contains single positive integer - K.

Output

Output should contain a single line that contains single positive integer - N.

Sample Input

1

4

Sample Output

102564

--------------------------------------------------------------------------------
...全文
17 2 点赞 打赏 收藏 举报

2 条回复

nobush 2004-05-03
#include<stdio.h>

int main()
{
int k;
long n,out;
printf("please input a integer between 1 and 10000: ");
scanf("%d",&k);
while(n=k,n<10)n+=k;
/*check the number*/
do{
int d;
long base=10;
while(base<=n)base*=10;
base/=10;
/*deal the first decimal digit*/
d=n/base;
out=n%base;
out=out*10+d;
if(n==out*k)
{
printf("the minimal integer is %ld\n",out);
return 0;
}
n+=k;
}while(n>=0);
printf("no marched!\n");
return 1;
}

/*================= result:======================*/
/*-
-
-
-4 —— 102564
-5 —— 714285
-
-
-
-
-10 —— 10
…… -*/
• 打赏
• 举报

rorot 2004-04-30

• 打赏
• 举报

C语言

6.5w+

C语言相关问题讨论

2004-04-30 06:29