Changlong's bother

描述

Changlong is a handsome and clever boy and he is admired by many beautiful girls. Every day he received tens of thousands of letters form girls which express their intense desire to be his life companion. You see, Changlong is very tired of this and one day he get an idea to avoid this bother. He declares:

Only those clever girls who can solve the problem below have the qualification to be his wife.

Changlong’s problem can be formulated like this:

There is one interesting sequence of numbers a1, a2,…an, this sequence has a very attractive property that every number appears exactly p times except a particular number t, which occurs q times. How to extract this particular number t from this sequence? In order to let this problem more mysterious, Changlong assumes that the involved number p, q in his problem are prime to each other, i.e., gcd(p, q)=1.

Changlong’s method works very well. After his declaration, the number of received letter has decrease sufficiently. The girls are beginning to think over the problem with continuous strenuous effort, no sooner later they find this problem is beyond their ability. So most of them give up, but there is still a beautiful girl who is persistent in this problem. One day this girl comes across you and she invites you to help her.

输入

At the first line of the input is an integer k (0 < k <= 100), the number of test cases.
 For each test case, there will be a line containing three integers: n (0 < n <= 10^7), p, q (1 < p, q < 200, gcd (p, q) =1) and a line containing n elements ai (0 < ai < 10^7) of the sequence.

输出

For each test case, you should first output a line with “Case #:”,where # is the id of the test case, then you should output the particular number t, i.e., the number which occurs q times in the sequence.

样例输入

2
8 3 2
1 2 1 2 1 2 3 3
7 4 3
1 1 1 1 2 2 2

样例输出

Case 1:
3
Case 2:
2

题意:
给你n个数其中有n-1个数出现了p次,一个数出现了q次,你要找出这个只出现了q次的数字
一开始做的时候直接用map标记,超内存,后面才知道原来用数位标记一下这么简单。太菜了
代码:

#include<bits/stdc++.h>
using namespace std;
int a[30];
inline int read()
{
    int xx=0,ff=1;
    char ch;
    ch=getchar();
    while(ch>'9'||ch<'0')
    {
        if(ch=='-') ff=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        xx=(xx<<3)+(xx<<1)+ch-'0';
        ch=getchar();
    }
    return xx*ff;
}
int main()
{
    int t=read();
    for(int i=1;i<=t;i++){
        memset(a,0,sizeof(a));
        int n,p,q,x,sum=0;
        n=read(),p=read(),q=read();
        for(int j=0;j<n;j++){
            x=read();
            for(int k=0;x&&k<30;k++){
                if(x&1) a[k]++;
                x=x>>1;
            }
        }
        int temp=1;
        for(int j=0;j<=25;j++){
            if(a[j]%p!=0){
                sum+=temp;
            }
            temp*=2;
        }
        printf("Case %d:\n%d\n",i,sum);
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
一、交际用语 1、- Good morning, John . How are you doing? - _________ A:I'm pleased. B:Good night. C:Not so bad. And you? D:How do you do? 2、- Good-bye for now. - _________ A:The same to you. B:That's OK. C:See you. D:Long time no see. 3、Happy New Year to you. ____________. A:The same to you B:Yes, I'm happy C:What about you D:Very well, thanks 4、- How tall is your sister? - _________ A:She is not very well. B:She is 28 years old. C:She is very nice. D:She is as tall as I am. 5、- How do I get to the cinema? - _________ A:It's very far. B:Yes, there is a cinema near here. C:It's well known. D:Go down this street and turn left. 6、How do you like the story? ____________. A:I'd like to read it B:I like it very much C:fine, thank you D:It's very interesting 7、- What does Peter do? - _________ A:He's good at fixing things. B:He can speak good German. C:He does the washing-up after supper. D:He's a language teacher. 8、- When are you going on holiday? - _________ A:Last night. B:Next week. C:By plane. D:With my brother. 9、- What do you do? - _________ A:What do you do? B:Fine, thank you. C:I'm a college student. D:I do well in my studies. 10、- This is a challenging job. Who wants it? - _________ A:I'll take it. B:It's a good idea. C:You bet! D:No sweat! 11、- Excuse me, could you tell me the time? - _________ A:You'd better buy a watch. B:It's three thirty by my watch. C:Can you see the clock? D:It's late I think. 12、- Welcome to Unitex International. I hope you will enjoy your work here. - _________ A:I can earn a lot. B:Is this a good firm? C:I am sure I will. D:You are very kind. 13、- That's a beautiful cat. I wonder who it belongs to. - _________ A:It belongs to the Browns. B:The cat is my favourite too. C:Mind your own business. D:I can't say anything more. 14、- _________ - You too! A:Merry Christmas! B:What a beautiful day! C:Help yourself! D:It's very kind of you! 15、- I hope you have a most happy and prosperous new year! - _________ A:You are welcome! B:How smart you are! C:The same to you! D:Nice going! 16、- Nice to see you again, Mr. Smith. How are you? - _________ A:I miss you. B:Fine. Thank you. And you? C:Are you OK? D:This way, please. 17、- Excuse me, can you tell me the way to the bus stop? - _________ A:Yes, go straight down this way to the end. B:Why do you ask me the way? C:Yes, I will. D:No, I can't tell you that. 18、- Can I help you, sir? - _________ A:No, I don't need your help. B:Yes. I'd like to withdraw some money. C:Well, leave me alone. D:Don't bother me! 19、- Where is the Loan Department, please? - _________ A:Who are you? B:This way, please. C:I don't want to say anything. D:What can I do for you? 20、- Would you like to see a film? - _________ A:Yes, I'd love to. B:Do it, please. C:No, you like it? D:How do you do? 21、― Hi! George. How are you? ― _________________ A:That's all right. B:Don't mention it. C:How are you? D:Fine, thanks. And you? 22、― Excuse me, I'm afraid you've overcharged me. ― ________________ A:Oh, really? B:That's all right. C:That's fine. D:You're welcome. 23、-Welcome to Beijing! -_____________ A:Thank you. B:Oh, good. C:How do you do? D:That's all right. 24、How could you say that? ___________. I did not mean to hurt you. A:Excuse me B:I won't regret C:I'm really sorry D:That's all right 25、- I've heard that you are going to Thailand? - Yes, I'll leave on Sunday. - That's great! _______ - Thank you! A:Have a nice journey! B:Watch out! C:How are you! D:You are so smart! 26、- Can I borrow your digital camera for a couple of days? - _______ A:Yes, you may not borrow. B:Yes, go on. C:Sure, here you are. Enjoy your journey. D:It doesn't matter. 27、- Good night and thanks again. - _______ A:You can't say that. B:No, no. It's what I can do. C:How can you say that. D:Good night. 28、- _______? - It's Friday. A:What day is it? B:What's the date today? C:What's the time? D:What time is it? 29、Would you mind if I use your car? Of course not. _____________. A:I'm sorry I can't B:I'm afraid not C:It's over there D:I have no car 30、-This is Mr. Green and this is Mr. Brown. -_____________. A:How do you do B:How are you C:Fine, thank you D:Hi, how are you getting on 31、- What would you like to have, meat or fish? - _____________________. A:Either will do B:Yes, I like meat C:Yes, I like fish D:No, they are not my favorite 32、- Would you rather come on Friday or Saturday? - __________________. A:Yes, of course B:No, thanks C:It doesn't matter D:Friday 33、- I believe we've met somewhere before. - No, ____________________. A:it isn't the same B:it can't be right C:I don't think so D:I'd rather not 34、--Could I use your bike for a moment? --_____ A:It's well. B:It doesn't matter. C:By all means. D:I have no idea. 35、--Could I borrow your car for a few days? --_____ A:Yes, you may borrow. B:Yes, go on. C:Sure, here your are. Enjoy your journey. D:It doesn't matter. 36、- Do you mind if I switch off the radio? - ___________. Go ahead. A:Never mind B:No way C:No, not at all D:No, you'd better not 37、--Excuse me, but can you tell me the way to the post office? --_____ A:Don't ask that. B:Sorry, I'm a stranger here. C:No, I can't say that. D:No, you're driving too fast. 38、- I've got your invitation. - Oh, good. ______ A:Can you come? B:Thanks a lot. C:I'll take it. D:May I help you? 39、You haven't been to Beijing, have you? ____________. How I wish to go there. A:No, I haven't B:Yes, I have C:No, I have D:Yes, I haven't 40、Has Alice had an accident? ____________. A:I don't hope so B:I hope no C:I hope not D:She didn't say to 41、-- How are you today? --___________, thank you. A:Fine B:Good C:Nice D:Great 42、-- How are your parents? -- __________. A:I'm OK, thanks B:She is well, thanks C:They are both fine, thanks D:He is well, thanks 43、-- _________ -- Fine, thanks. A:How do you do? B:Hello! C:Nice to meet you。 D:How are you? 44、-- How is your father today? -- __________, thanks. A:He is over forty B:He's a doctor C:He's much better D:He's Brown 45、--Hi! Jim. This is my brother Peter. -- _________ A:How are you? B:Fine, thank you. C:Nice to meet you. D:You are very kind. 46、--Hi, Jim! Nice to meet you. -- _________. A:Certainly B:Many thanks C:OK D:Nice to meet you, too 47、-- It's nearly ten o'clock. It's time for you to go to bed, Kate! --OK. _________, Dad. A:See you later B:Good-bye C:Good evening D:Good night 48、--Excuse me, could you tell me how to get to the post office? -- _____________. A:You can't miss it B:I don't know C:No, I can't D:Sorry, but I am a stranger here myself 49、-- Let me introduce myself. I am Albert. -- ______________. A:What a pleasure B:It' s my pleasure C:Pleased to meet you D:I'm very pleased 50、-What can I do for you? -_________ A:Let me have a watch. B:Could you show me the watch? C:Yes, you can. Give me the watch. D:The watch, please don't give me the pen. 51、---I'll fly to Shanghai on business next Friday. ---____________________________ A:That's very nice of you. B:I don't think so. C:Can't you go? D:Have a good trip. 52、--- The summer vacation is coming in a few days. I'll share the holidays with my daughter by traveling. ---- ______. A:Congratulations! B:Nice to meet you! C:Have a good trip! D:It's very kind of you. 53、---Which sweater do you like better? --- ________. A:Good idea B:Yes, it's nice C:Yes, please D:I can't decide 答案:D 54、-Morning, sir.______ -I've learnt that silk is famous here. Can I get some? A:Can you help me? B:What's the matter with you? C:Can you give me a hand? D:Anything I can do for you? 55、- How do you do? - ______ A:Fine, thank you. B:How do you do? C:Not too bad. D:Very well. 56、- I heard Susan surprised her teacher by working hard. - Yes, ______ A:her teacher worked hard. B:Susan worked hard. C:the teacher was surprising. D:Susan was surprised. 57、- Hello, how are you? - ______ A:Hello, how are you? B:How do you do? C:Fine, thank you. D:That's OK. 58、---How is Mr Brown? -- ______________. A:He is tall and beautiful B:He is very strict with us C:He is fine D:He is in an expensive car 59、---How is your mother these days? --Oh, _____________. A:She is good B:She is not very well C:Never mind D:That's all right 60、---This is John. -- ___________ A:Oh, I have never seen you. B:Yes, I am glad. C:Hello, John. Nice to meet you. D:How are you? 61、---I have lost my new English dictionary. -- _________ A:What a pity! B:It's nothing. C:It doesn't matter. D:Not at all. 62、-- I failed the maths exam again. -- _________ A:Well done. B:What a pity! C:That's right. D:I'm glad. 63、-- Hi, I'm Liz. -- _________ A:Hi, nice to see you. B:What do people call you? C:Fine, and you? D:How do you do? 64、--_________? --I'm from Mexico. A:Where are you from B:How do you come here C:What's your name D:How far is it 65、--Excuse me, is there any grocery store around here? --Yes, _________on Pine street. It's not far from here. A:you like it B:there is one C:you'll catch it D:it's warm and foggy 66、--_______, could you please tell me where the school library is? --Sure. It's at the back of the campus, about five minutes' walk from here. A:Excuse me B:Pardon me C:That's right D:Thank you 67、--Shall I drive you to the railway station? --Oh, don't bother about it. I'll take a taxi. --Well, __________! --Thank you and good-bye! A:come on B:help C:have it checked up D:have a nice trip 68、--I went to the beach and got plenty of rest. --___________. You looked tired last time I saw you. A:I hope so B:Really C:I'm glad you did D:The sound was nice 69、--Are you feeling all right today? --Not really. --__________________. A:Oh, I see B:It doesn't matter C:You'd better be happyD:I am sorry to hear that 70、--How can I get to the nearest post office? --_______________ A:It is a long way from here. B:Sorry, I am new here. C:Why don't you walk? D:Here it is. 71、-Oh, dear! I've lost my new watch. -_____ A:I'm sad. B:That's right. C:That's all right. D:What a pity! 72、-My brother fell off his bike and hurt himself. -______ A:How careless he was! B:I'm sorry to hear that.C:That's too bad. D:I'm bad to hear that. 73、--What can I do for you, sir? --_____________ A:Can you lend me some money? B:Nothing. C:I want a pair of shoes. D:Whatever. 74、-I had a really good weekend at my uncle's. -____________. A:Oh, that's very nice of you B:Certainly C:It's a pleasure D:Oh, I'm glad to hear that 75、- Hello, I'm Harry Potter. - Hello, my name is Charles Green, but ______. A:call my Charles B:call me at Charles C:call me Charles D:call Charles me 76、- Who's speaking? - This is Tom . A:speaks B:spoken C:speaking D:saying 77、- - He teaches physics in a school. A:What does your father want to do? B:Who is your father? C:What is your father? D:Where is your father now? 78、- Could you help me with my physics, please? - ________ A:No, no way. B:No, I couldn't. C:No, I can't. D:Sorry I can't. I have to go to a meeting right now. 79、- Could I speak to Don Watkins, please? - ________ A:Speaking, please. B:Oh, how are you? C:I'm listening. D:I'm Don. 80、- Happy birthday to you! - ______! A:Happy birthday to youB:I'm very gladC:That's all rightD:Thank you 81、- Thank you for inviting me. - _______ A:I really had a happy time. B:Oh, it's too late. C:Thank you for coming. D:Oh, so slowly? 82、Have a good day! ___________. A:You got it too B:The same to you C:Yes, thank you D:The same as you 83、-Will you be free tomorrow morning? -___________. A:No, I'll be busy B:What is the matter? C:I'm sorry I won't be free then D:No, I'll have no time 84、I'm sorry to hear that you failed in the exam. ___________. A:Not at all B:Oh, thank you.That's very kind of you. C:You are welcome D:Yes, I'm really sorry 85、May I use your dictionary? ____________. A:Yes, here you are B:No, you won't C:Never mind D:Sorry here it is 86、--Will you please give the note to him? -- ______________. A:Certainly, I'll give it to him B:No, please not C:Sorry, I don't D:Yes, please do 87、--I was born in Boston, but I studied in New York._________? --I was born in New York, but studied in Boston. A:What do you do B:And you C:Where were you D:Do you 88、-- May I borrow your umbrella for a moment? -- ______________. A:No, you can't do it B:Sorry, but you may not C:Well, I am afraid I am going to use it myself D:Of course not. I'm going to need it myself 89、--What does your father do? -- ___________. A:He is cleaning the street B:He is forty C:He is a farmer D:He is all right 90、-- _____________? -- Do you have a toy horse? A:What do you want to sell B:Shall I help you C:What can I do for you D:Do you like a toy horse 91、- I'm going to take my entrance test tomorrow. - _______! A:Good luck B:Cheers C:Come on D:Congratulations 92、-_______? -He's a tall man with short hair. A:How is he B:What does he like C:What is he D:What does he look like 93、- Does that tea have enough sugar in it? - ______ A:Yes, it is. Thank you. B:Yes, it does. Thank you. C:Yes, I will. Thank you. D:Yes, I do. I like it. 94、- Do you know if Mrs. Brown is still living in London? - ______ A:Yes, she is. B:Yes, it is. C:Yes, they are. D:Yes, he is. 95、- How many students went to the hockey game? - ______ A:None of them go to the hockey game. B:They seldom go to the hockey game. C:They usually went to the hockey game. D:All of them went to the hockey game. 96、--- Happy New Year to you and your parents! -- ________________. A:Thank you B:You are happy, too C:Yes, we are happy D:The same to you 97、-- I'm sorry to trouble you. Can I borrow a pen, please? -- ___________. A:Yes, you can B:Certainly! It is here C:She's welcome D:Thank you 98、--___________! Welcome to the party. --Merry Christmas! It's very kind of you to invite us. A:Happy birthday B:Merry Christmas C:Congratulations D:Have a good day 99、--Thank God.It's Friday again.A nice weekend! -- ______. A:Me too B:Yes,I'll be free then C:That's all right D:The same to you 100、--This week, I will travel to Japan. --_____________. A:Have a good time! B:Let me go with you C:Do you have money? D:Don't joke

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值