HDOJ 题目2303 The Embarrassed Cryptographer(数学)

时间:2022-11-27 12:42:50 作者:酒心纪元 综合材料 收藏本文 下载本文

“酒心纪元”通过精心收集,向本站投稿了6篇HDOJ 题目2303 The Embarrassed Cryptographer(数学),这里小编给大家分享一些HDOJ 题目2303 The Embarrassed Cryptographer(数学),方便大家学习。

篇1:HDOJ 题目2303 The Embarrassed Cryptographer(数学)

The Embarrassed Cryptographer

Time Limit: 3000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 563 Accepted Submission(s): 172

Problem Description The young and very promising cryptographer Odd Even has implemented the security module of a large system with thousands of users, which is now in use in his company. The cryptographic keys are created from the product of two primes, and are believed to be secure because there is no known method for factoring such a product effectively.

What Odd Even did not think of, was that both factors in a key should be large, not just their product. It is now possible that some of the users of the system have weak keys. In a desperate attempt not to be fired, Odd Even secretly goes through all the users keys, to check if they are strong enough. He uses his very poweful Atari, and is especially careful when checking his boss' key.

Input The input consists of no more than 20 test cases. Each test case is a line with the integers 4 <= K <= 10100and 2 <= L <= 106. K is the key itself, a product of two primes. L is the wanted minimum size of the factors in the key. The input set is terminated by a case where K = 0 and L = 0.

Output For each number K, if one of its factors are strictly less than the required L, your program should output “BAD p”, where p is the smallest factor in K. Otherwise, it should output “GOOD”. Cases should be separated by a line-break.

Sample Input

143 10143 20667 20667 302573 302573 400 0

Sample Output

GOODBAD 11GOODBAD 23GOODBAD 31

Source NCPC2005

Recommend zty | We have carefully selected several similar problems for you: 2300 2308 2301 2305 2306 输入一个大数和一个整数k,然后看看那个大大数能不能整除一个素数,要是可以看看那个素数比k大还是小,要是小就输出BAD,并把那个素数输出出来,否则输出GOOD ac代码

#include#includeint is[1000010],prim[10000100],num=0,k;void fun{ int i,j; for(i=2;i<1000010;i++) { if(!is[i]) { prim[num++]=i; for(j=i+i;j<1000010;j+=i) { is[j]=1; } } }}char s[220];int main(){ fun(); while(scanf(“%s %d”,s,&k)!=EOF) { if(strcmp(s,“0”)==0&&k==0) break; int len=strlen(s),i,j,sum; for(i=0;i

篇2:HDOJ 题目2614 Beat(DFS)

Beat

Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 837 Accepted Submission(s): 524

Problem Description Zty is a man that always full of enthusiasm. He wants to solve every kind of difficulty ACM problem in the world. And he has a habit that he does not like to solve

a problem that is easy than problem he had solved. Now yifenfei give him n difficulty problems, and tell him their relative time to solve it after solving the other one.

You should help zty to find a order of solving problems to solve more difficulty problem.

You may sure zty first solve the problem 0 by costing 0 minute. Zty always choose cost more or equal time’s problem to solve.

Input The input contains multiple test cases.

Each test case include, first one integer n ( 2< n < 15).express the number of problem.

Than n lines, each line include n integer Tij ( 0<=Tij<10), the i’s row and j’s col integer Tij express after solving the problem i, will cost Tij minute to solve the problem j.

Output For each test case output the maximum number of problem zty can solved.

Sample Input

30 0 01 0 11 0 030 2 21 0 11 1 050 1 2 3 10 0 2 3 10 0 0 3 10 0 0 0 20 0 0 0 0

Sample Output

324HintHint: sample one, as we know zty always solve problem 0 by costing 0 minute. So after solving problem 0, he can choose problem 1 and problem 2, because T01 >=0 and T02>=0. But if zty chooses to solve problem 1, he can not solve problem 2, because T12 < T01. So zty can choose solve the problem 2 second, than solve the problem 1.

Author yifenfei

Source 奋斗的年代

Recommend yifenfei | We have carefully selected several similar problems for you: 1426 2616 1312 1501 2181 ac代码

#include#include#define max(a,b) (a>b?a:b)int map[1010][1010],vis[1010];int ans,n;void dfs(int i,int len,int num){ ans=max(ans,len); if(len==n) return; for(int j=0;j=num) { vis[j]=1; dfs(j,len+1,map[i][j]); vis[j]=0; } } }}int main(){ //int n; while(scanf(“%d”,&n)!=EOF) { int i,j; for(i=0;i

篇3:HDOJ题目3309 Roll The Cube(BFS)

Roll The Cube

Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 502 Accepted Submission(s): 181

Problem Description This is a simple game.The goal of the game is to roll two balls to two holes each.

'B' -- ball

'H' -- hole

'.' -- land

'*' -- wall

Remember when a ball rolls into a hole, they(the ball and the hole) disappeared, that is , 'H' + 'B' = '.'.

Now you are controlling two balls at the same time.Up, down , left , right --- once one of these keys is pressed, balls exist roll to that direction, for example , you pressed up , two balls both roll up.

A ball will stay where it is if its next point is a wall, and balls can't be overlap.

Your code should give the minimun times you press the keys to achieve the goal.

Input First there's an integer T(T<=100) indicating the case number.

Then T blocks , each block has two integers n , m (n , m <= 22) indicating size of the map.

Then n lines each with m characters.

There'll always be two balls(B) and two holes(H) in a map.

The boundary of the map is always walls(*).

Output The minimum times you press to achieve the goal.

Tell me “Sorry , sir , my poor program fails to get an answer.” if you can never achieve the goal.

Sample Input

46 3****B**B**H**H****4 4*****BB**HH*****4 4*****BH**HB*****5 6*******.BB***.H*H**..*.*******

Sample Output

312Sorry , sir , my poor program fails to get an answer.

Author MadFroG

Source HDOJ Monthly Contest – 2010.02.06

Recommend wxl | We have carefully selected several similar problems for you: 3308 3314 3307 3306 3310 ac代码

#include#include#include#includeusing namespace std;int n,m,vis[25][25][25][25],sx[2],sy[2];char map[25][25];int dx[4]={0,1,0,-1};int dy[4]={1,0,-1,0};struct s{ int x[2],y[2],step,b[2],h[2]; //friend bool operator <(s a,s b) //{ // return a.step>b.step; //}}a,temp;int bfs{ memset(vis,0,sizeof(vis)); a.x[0]=sx[0],a.x[1]=sx[1]; a.y[0]=sy[0],a.y[1]=sy[1]; a.b[0]=a.b[1]=a.h[0]=a.h[1]=0; vis[sx[0]][sy[0]][sx[1]][sy[1]]=1; a.step=0; //priority_queueq; queueq; q.push(a); while(!q.empty()) { int i,j; //a=q.top(); a=q.front(); q.pop(); for(i=0;i<4;i++) { temp=a; for(j=0;j<2;j++) { if(temp.b[j]) continue; temp.x[j]=a.x[j]+dx[i]; temp.y[j]=a.y[j]+dy[i]; if(map[temp.x[j]][temp.y[j]]=='*') { temp.x[j]=a.x[j]; temp.y[j]=a.y[j]; } }if(vis[temp.x[0]][temp.y[0]][temp.x[1]][temp.y[1]]) continue; if(temp.x[0]==temp.x[1]&&temp.y[0]==temp.y[1]&&temp.b[0]+temp.b[1]==0) continue; vis[temp.x[0]][temp.y[0]][temp.x[1]][temp.y[1]]=1; temp.step=a.step+1; int flag=1; for(j=0;j<2;j++) { int now=map[temp.x[j]][temp.y[j]]; if(now<2&&!temp.h[now]) { temp.h[now]=1; temp.b[j]=1; } if(!temp.b[j]) flag=0; } if(flag) return temp.step; q.push(temp); } } return -1;}int main(){ int t; scanf(“%d”,&t); while(t--) { int i,j; scanf(“%d%d”,&n,&m); int cnt=0,cot=0; for(i=0;i

篇4:HDOJ 题目4786 Fibonacci Tree(克鲁斯卡尔)

Fibonacci Tree

Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 2562 Accepted Submission(s): 816

Problem Description Coach Pang is interested in Fibonacci numbers while Uncle Yang wants him to do some research on Spanning Tree. So Coach Pang decides to solve the following problem:

Consider a bidirectional graph G with N vertices and M edges. All edges are painted into either white or black. Can we find a Spanning Tree with some positive Fibonacci number of white edges?

(Fibonacci number is defined as 1, 2, 3, 5, 8, ... )

Input The first line of the input contains an integer T, the number of test cases.

For each test case, the first line contains two integers N(1 <= N <= 105) and M(0 <= M <= 105).

Then M lines follow, each contains three integers u, v (1 <= u,v <= N, u v) and c (0 <= c <= 1), indicating an edge between u and v with a color c (1 for white and 0 for black).

Output For each test case, output a line “Case #x: s”. x is the case number and s is either “Yes” or “No” (without quotes) representing the answer to the problem.

Sample Input

24 41 2 12 3 13 4 11 4 05 61 2 11 3 11 4 11 5 13 5 14 2 1

Sample Output

Case #1: YesCase #2: No

Source 2013 Asia Chengdu Regional Contest

Recommend We have carefully selected several similar problems for you: 5193 5192 5191 5190 5189 ac代码

#include#include#includestruct s{ int u,v,w;}edge[100100];int pre[100100],a[100100],n,m;int cmp1(const void *a,const void *b){ return (*(struct s *)a).w-(*(struct s *)b).w;}int cmp2(const void *a,const void *b){ return (*(struct s *)b).w-(*(struct s *)a).w;}void init(int n){ int i; for(i=0;i<=n;i++) pre[i]=i;}void fun(){ int i; a[1]=1;a[2]=2; for(i=3;i<100100;i++) a[i]=a[i-1]+a[i-2];}int find(int x){ if(x==pre[x]) return pre[x]; return pre[x]=find(pre[x]);}int ku(){ init(n); int ans=0,i,j; for(i=0;i1) return -1; return ans;}int main(){ int t,c=0; scanf(“%d”,&t); fun(); while(t--) { //int n,m int i,l,r; scanf(“%d%d”,&n,&m); //init(n); for(i=0;ir) break; if(a[i]<=r&&a[i]>=l) { printf(“Case #%d: Yesn”,++c); flag=1; break; } } if(!flag) printf(“Case #%d: Non”,++c); } }}

篇5:数学急转弯题目

数学急转弯题目(一)

1. 一堆西瓜,一半的一半比一半的一半的一半少半个,请问这堆西瓜有多少个?答案:2个

2. 请问:将18平均分成两份,却不得9,还会得几 答案:10(从中间分)

3. 小丽和妈妈买了8个苹果,妈妈让小丽把这些苹果装进5个口袋中,每个口袋里都是双数,你能做到吗?答案:每条口袋各装2个苹果,最后将所有4条口袋装进第5条口

4. 爸爸妈妈有四个女儿,每个女儿有一个弟弟。请问这个家里有多少人?答案:7个(四个女儿,一个弟弟,爸爸妈妈)

5. 一张方桌据掉一个角,还有几个角?答案:5个角

6. 一溜(提示:注意谐音)三棵树,要拴10匹马,只能拴单不能拴双,请问怎样栓?答案:1棵树拴一匹马正好(“一溜”正好就是一六,所以1+6+3=10)

7. 什么数字让女士又爱又恨?答案:三八

8. 请你把九匹马平均放到十个马圈里,并让每个马圈里的马的数目都相同,怎么分?答案:把九匹马放到一个马圈里,然后在这个马圈外再套九个马

9. 电单车时速80公里,向北行驶。有时速20公里的东风,请问电单车的烟朝那个方向吹?答案:电车是没有烟的

10. 火车由北京到上海需要6小时,行使3小时后,火车该在什么地方?答案:在车轨上

经典脑筋急转弯(二)

1. 什么东西你有,别人也有,虽然是身外之物,却不能交换?【 答案:姓名 】

2. 战场上,子弹最密集的地方在哪里?【 答案:在丹药运输车上 】

3. 太阳和月亮在一起是哪一天?【 答案:明天 】

4. 曹孟德赤壁惨败。(打二歌星)【 答案:孙悦、刘欢 】

5. 弃文就武(打一成语)?【 答案:投笔从戎 】

6. 阎王爷写日记(打一成语)?【 答案:鬼话连篇 】

7. 什么桥下没水?【 答案:立交桥 】

8. 小明在一场激烈木仓战后,身中数弹,血流如注,然而他仍能精神百倍地回家吃饭,为什么?【 答案:他在拍戏 】

9. 什么英文字母最多人喜欢听?【 答案:cd 】

10. 什么酒不能喝?【 答案:碘酒 】

11. 什么东西咬牙切齿?【 答案:拉链 】

12. 森林里有一条眼镜蛇,可是它从来不咬人,这是为什么呢? 答案:森林里没人

13. 请问木字多一撇是什么字? 答案:移

精选脑筋急转弯(三)

1. 长安一片月(打一字)?【 答案:胀 】

2. 一辆火车由甲地到乙地全程需要6小时才可到达,如今行驶了3小时,火车现在应该在什么地方?【 答案:在铁轨上 】

3. 毛毛从20楼跳下去,为什么没有事?【 答案:往里跳 】

4. 水陆各半。(打一拉丁美洲国家名)【 答案:海地 】

5. 爱看斗牛。(打一非洲地名)【 答案:好望角 】

6. 什么笔不能写?【 答案:试电笔 】

7. 牛的舌头和尾巴在什么时候遇在一起?【 答案:餐厅里 】

8. 小丽和妈妈买了8个苹果,妈妈让小丽把这些苹果装进5个口袋中,每个口袋里都是双数,你能做到吗? 【 答案:每条口袋各装2个苹果,最后将所有4条口袋装进第5条口袋 】

9. 海中绿洲(打一城市)?【 答案:青岛 】

10. 华先生有个本领,那就是能让见到他的人,都会自动手心朝上。这是怎么回事?【 答案:因为他是个中医 】

11. 医生给了你三颗药丸要你每半个小时吃一颗请问吃完需要多长时间?【 答案:一个小时 】

12. 一间牢房中关押着两名犯人,其中一个因偷窃要关一年,另一个是抢动杀人犯,却只关两周,为什么?【 答案:关两周后木仓决 】

13. 任何人必须去的地方是哪里?【 答案:厕所 】

篇6:数学题目脑筋急转弯

1. 大勇说他和学校的老师很熟,在学校里哪里都能进去,但小涵偏说他有一处地方永远也不能进去,是什么地方呢? 答案:女厕所

2. 一只皮球和一只铁球从高楼上掉下来,谁先落地? 答案:铁球

3. 星期二过去是星期三,星期三过去是星期四,星期四过去却是星期天,为什么 答案:多撕了两张日历

4. 有个胖子上了公共汽车,没有月票,也没有买票,售票员为什么让他从起点坐到终点? 答案:是个司机

5. 小明岁,小亮岁,小涵比他们俩各相差一岁,那么小涵有几岁?答案:四岁

6. 涵捉到一只小鸟,她把小鸟放在桌子上,小鸟却没有飞,是什么原因? 答案:鸟已死

7. 大勇总爱吹牛,他说他能不用任何容器将一杯水带走,小朋友都不相信,但他却做到了,是怎么回事呢? 答案:将杯子倒扣在装满水的盆子里

8. 在做游戏是,你是司令,你手下有两名军长,五名团长,十个排长和二十五名士兵,那么他们的司令今年几岁了? 答案:你几岁就是几岁

9. 小涵的妈妈熨烫衣服,一件衣服要五分钟,一条裤子要三分钟,现在有三件小衣服,一条裤子,小涵的妈妈要几分钟才能全部熨烫完? 答案:分钟

10. 猫和猪有何区别? 答案:一种是宠物一种是食物

11. 一场大雨,忙着耕种的农人纷纷走避,却仍有一人不走,为什么? 答案:它是稻草人

12. 墙壁上爬着三只壁虎,一只壁虎掉下后没多久,另外两只也跟着掉下来,到底发生什么事情? 答案:因为一只在打瞌睡,另两只拍手叫好,也掉下来了,

13. 某岛上有只乌龟,正中央是棵椰子树,岛的旁边还有一座岛,乌龟想过去,但又不太会游水,请问它该怎么过? 答案:他还在想

14. 公车来了,一位穿长裙的小姐投了块钱,司机让她上车,第二位穿迷你裙的小姐投了块钱,司机也让她上车,第三位小姐没投钱,司机还是让她上车,为什么? 答案:她用车票

15. 为什么空军的阿兵哥比较少? 答案:空军嘛当然比较少啦

16. 武士刀和日本人有什么关系? 答案:他们是剖腹之交

17. 餐厅里,有两对母女在用餐,每人各叫一个元的牛排,付帐是却只付元,为什么? 答案:这两对母女是奶奶妈妈女儿,

18. 阿美念T大哲学系,她每天早上都挤八点的公车去上学,今天她挤上车后恰好有一空位,阿美坐上去后不知不觉地就睡着了,突然一觉醒来,发现全车除了她空无一人,但车子还在前进,为什么?答案:车子抛锚了司机和乘客都在下面推车

19. 走进一家店,看见老板和客人正在议价,老板拼命杀价,而顾客却一直抬高价钱,为什么? 答案:因为客人来卖车

20. 某人买了易开罐农药,打算自杀,他的情人也要求同归与尽,但农药份量必须一整罐才会毙命,结果两个人都死了,为什么? 答案:打开农药罐已坏再拿一罐

21. 什么样的食物最让人倒胃口? 答案:吃了大半个苹果里边藏着半条虫子

22. 小陈礼拜天早上赶到西门町去看早场电影,到了西门町,却看不到半个人,为什么 答案:人有好多个就是没有半个

23. 有一个婴儿喝了牛奶之后,一星期重了十公斤,为什么? 答案:那是一头牛

24. 小明带一百元去买一个七十五元的东西,但老板却只找了五块钱给他,为什么? 答案:小明只拿元给老板

25. 为什么李爷爷被歹徒抢走了十万元之后,不但不心疼,反而哈哈大笑? 答案:因为那名歹徒是他上幼儿园的孙子扮演的

26. “失败为成功之母”,那成功为失败的什么? 答案:反义词

27. 有一个胖子和瘦子走在一起,胖子突然被掉落的高压电线打倒,胖子死了,而瘦子并未碰到胖子或电线,可是他也死了,为什么? 答案:瘦子被油炸死了

28. 某人有喝一打高粱的酒量,但今晚他只喝了半瓶啤酒就醉了,为什么? 答案:他不久前才刚喝了一打高梁

29. 什么时候会看到最多的星星? 答案:踩到地雷

30. 恐龙为什么会灭亡? 答案:那个时候没有动物保护协会

二年级数学练习题目

八年级数学的测试题目

二年级数学教学论文题目

七年级数学测试题目及答案

二年级数学下册测试题目

数学反比例函数单元综合测试题目

初中数学脑筋急转弯题目带答案

小学数学教学方面的论文题目

应届毕业生面试题目-数学趣题解析

一年级趣味数学比赛题目附答案

HDOJ 题目2303 The Embarrassed Cryptographer(数学)(合集6篇)

欢迎下载DOC格式的HDOJ 题目2303 The Embarrassed Cryptographer(数学),但愿能给您带来参考作用!
推荐度: 推荐 推荐 推荐 推荐 推荐
点击下载文档 文档为doc格式
点击下载本文文档