| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4608 人关注过本帖
标题:[讨论]第五期题目,大家做做.
只看楼主 加入收藏
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
结帖率:50%
收藏
 问题点数:0 回复次数:49 
[讨论]第五期题目,大家做做.

再接再厉

Number Sequence

--------------------------------------------------------------------------------

Time limit: 1 Seconds Memory limit: 32768K
Total Submit: 1092 Accepted Submit: 307

--------------------------------------------------------------------------------

A single positive integer i is given. Write a program to find the digit located in the position i in the sequence of number groups S1S2...Sk. Each group Sk consists of a sequence of positive integer numbers ranging from 1 to k, written one after another.

For example, the first 80 digits of the sequence are as follows:

11212312341234512345612345671234567812345678912345678910123456789101112345678910


Input

The first line of the input file contains a single integer t (1 <= t <= 10), the number of test cases, followed by one line for each test case. The line for a test case contains the single integer i (1 <= i <= 2147483647)


Output

There should be one output line per test case containing the digit located in the position i.


Sample Input

2
8
3


Sample Output

2
2

/*解释一下:给定一个有规律的序列,它的每一个元素是由一位数字组成的,对输入一数,代表某元素在这个序列中的位置,输出这个元素,大家注意一下,10,11等等是拆开成2(3,4...)个数字的,也就占了两个位置.*/

搜索更多相关主题的帖子: 题目 limit Submit digit Sequence 
2006-12-10 19:42
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 

2^x mod n = 1

--------------------------------------------------------------------------------

Time limit: 1 Seconds Memory limit: 32768K
Total Submit: 4209 Accepted Submit: 1144

--------------------------------------------------------------------------------

Give a number n, find the minimum x that satisfies 2^x mod n = 1.


Input

One positive integer on each line, the value of n.


Output

If the minimum x exists, print a line with 2^x mod n = 1.

Print 2^? mod n = 1 otherwise.

You should replace x and n with specific numbers.


Sample Input

2
5


Sample Output

2^? mod 2 = 1
2^4 mod 5 = 1

/*找出满足2^x mod n==1的最小x,如果找不到,则输出时用?代替.*/


倚天照海花无数,流水高山心自知。
2006-12-10 19:48
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
得分:0 

这样对吗?
#include <stdio.h>
#include <stdlib.h>

int main()
{
int t, j;
long s;
while(scanf("%d", &t) != EOF)
{
for(j = 0;j < t;j ++)
{
scanf("%ld", &s);

int i, k;
for(i = 1;;i ++)
{
k = (i*(i + 1))/2 - s;
if(k >= 0)
break;
}
printf("%d\n",i - k);
}
}

return 0;
}


该学习了。。。
2006-12-10 20:16
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 

第一个没这么简单吧


倚天照海花无数,流水高山心自知。
2006-12-10 20:19
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
得分:0 
我测试了很多,都对了!

该学习了。。。
2006-12-10 20:22
zhanghuan_10
Rank: 1
等 级:新手上路
威 望:2
帖 子:751
专家分:0
注 册:2006-10-25
收藏
得分:0 

哦。我知道了!是不是最大的只能是10啊!


该学习了。。。
2006-12-10 20:26
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 
输入的数可以很大,但输出的数只有0 1 2 3 4 5 6 7 8 9 中的一个.

倚天照海花无数,流水高山心自知。
2006-12-10 20:52
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 
以下是引用zhanghuan_10在2006-12-10 20:16:46的发言:

这样对吗?
#include <stdio.h>
#include <stdlib.h>

int main()
{
int t, j;
long s;
while(scanf("%d", &t) != EOF)
{
for(j = 0;j < t;j ++)
{
scanf("%ld", &s);

int i, k;
for(i = 1;;i ++)
{
k = (i*(i + 1))/2 - s;
if(k >= 0)
break;
}
printf("%d\n",i - k);
}
}

return 0;
}

数据用long吧

[此贴子已经被作者于2006-12-10 20:58:15编辑过]


倚天照海花无数,流水高山心自知。
2006-12-10 20:55
hujian100
Rank: 1
等 级:新手上路
帖 子:69
专家分:0
注 册:2006-9-14
收藏
得分:0 
第二题答案:
#include <stdio.h>
#include <math.h>
main()
{
int n;
double x;
printf("Please input a positive integer:");
scanf("%d",&n);
if(n<=0)
printf("Error input!");
else
{
if(n%2==0||n==1)
printf("2^? mod %d = 1\n",n);
else
{
for(x=2;;x++)
if((int)pow(2,x)%n==1)
{
printf("2^%.0f mod %d = 1\n",x,n);
break;
}
}
}
}

[此贴子已经被作者于2006-12-10 22:19:19编辑过]


2006-12-10 22:14
nuciewth
Rank: 14Rank: 14Rank: 14Rank: 14
来 自:我爱龙龙
等 级:贵宾
威 望:104
帖 子:9786
专家分:208
注 册:2006-5-23
收藏
得分:0 
12
2^? mod 12 = 1
234
2^? mod 234 = 1
21
2^6 mod 21 = 1
223
2^37 mod 223 = 1
2345
2^132 mod 2345 = 1
23457
2^1116 mod 23457 = 1
1234567
2^5670 mod 1234567 = 1
1234321
2^111100 mod 1234321 = 1
19876765
2^1987676 mod 19876765 = 1
129826321
2^32456580 mod 129826321 = 1

倚天照海花无数,流水高山心自知。
2006-12-10 22:47
快速回复:[讨论]第五期题目,大家做做.
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013661 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved