acm-Nanjing University Eighth session of the program design Competition-Online race (2016.04.17)

Source: Internet
Author: User

A, Stealing sweets
Time limit:1000ms

Memory limit:65536kb

Description
Small fish like to eat sweets. He has two boxes of sweets, two boxes of candy, respectively, consisting of a string s and a string t composed of lowercase letters. Where ' a ' to ' z ' denotes a specific type of candy.
He was going to give it to a girl he liked, but for a girl, two boxes of candy can't make a difference (that is, the string s is exactly the same as T). So, he decided to steal a few pieces, his strategy for eating sweets is to pick a box of candy in two consecutive categories of candy, and then eat one of them. This policy can be used more than once.
For example, a box of sweets is ' rrrjj ', and he can turn this box of sweets into ' rrjj ' or ' RRRJ '. Now you have to tell the fish, after his many times to steal candy, two boxes of candy can give him like the girl. If you can output ' Yes ', if not output ' no '.
Input
The first line is a T, which represents the T group test data. The test data format for each group is as follows.
The first line represents the string s, and the second line represents the string T.
1≤t≤100
Each character of S, T would be between ' a ' and ' Z '.
1≤length of String s≤1000
1≤length of String t≤1000
Output
For each set of test data, the output is yes, or no.
Sample Input
2
Rrrjj
Rrrj
Rj
Jr
Sample Output
Yes
No
Hint
The first example of a topic:
First box of sweets: Rrrjj, RRJJ, RJJ, RJ
Second box of Sweets: RJ RRRJ-RRJ

Analysis: I think it is a string match, and then test instructions understand the wrong, and then began to write new, see this sentence "two consecutive same category of candy"

1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4 intMainvoid)5 {6     Chara[1100], b[1100], a1[1100], b1[1100],c;7     intI1,i, J, T, N;8 9scanf"%d", &t);Tenc =GetChar (); One          for(I1 =0; I1 < t;i1++) A         { - gets (a); - gets (b); thej =0; -              for(i =1; A[i]! =' /'; i++) -             { -                 if(A[i]! = a[i-1]) +                 { -A1[J] = a[i-1]; +J + +; A                 } at             } -A1[J] = a[i-1]; -J + +; -A1[J] =' /'; -j =0; -              for(i =1; B[i]! =' /'; i++) in             { -                 if(B[i]! = b[i-1]) to                 { +B1[J] = b[i-1]; -J + +; the                 } *             } $B1[J] = b[i-1];Panax NotoginsengJ + +; -B1[J] =' /'; the             if(strcmp (a1, b1) = =0) +printf"yes\n"); A             Else theprintf"no\n"); +         } -}

H, who is the strongest battleship!
Time limit:1000ms

Memory limit:65536kb

Description
Iowa came to the house of the first thing, is to find big and solo!
However, this is not good news, perhaps, guarding the house, or even Saeki Bay so disappeared ...
So, admiral June thought of a simple game, to distinguish their victory and defeat. The rules of the game are as follows: There are N heap of stones, each heap of stones have a[i] (1<=i<=n), each of them take a stone from one of the stones (only in one heap to take, not to take), and Big initiator, who took out the last stone, who lost. If big and win, output "yamato_saikou!", if Iowa win, output "meidikeji_shijiediyi!", if both sides can not win, output "sayonara_konosekai!".
Input
The first line enters a positive integer t (1 <= T <= 1000), which indicates that there is a T group of test data.
For each set of test data:
The first line is a positive integer, N (n<=1000), which indicates that there are n heap stones.
The second row n integers a[i] (1<=a[i]<=1000), which represents the number of stones per heap.
Output
If big and win, output "yamato_saikou!", if Iowa win, output "meidikeji_shijiediyi!", if both sides can not win, output "sayonara_konosekai!".
Sample Input
3
1
5
2
1 2
3
1 1 1
Sample Output
yamato_saikou!
yamato_saikou!
meidikeji_shijiediyi!

Thought: Anti-nim game, the topic gives this sentence, oneself feel circle, seem not to use

1#include <stdio.h>2 intMain ()3 {4     intT;5scanf"%d",&t);6      while(t--)7     {8         intn,s=0, m,c=0;9scanf"%d",&n);Tenm=N; One          while(n--) A         { -             intnum; -scanf"%d",&num); thes^=num; -             if(num>1) -C++; -         } +         if(!s&&!c| | (s&&c)) -printf"yamato_saikou!\n"); +         Else Aprintf"meidikeji_shijiediyi!\n"); at     } -}

C, Count_prime
Time limit:1000ms

Memory limit:65536kb

Description
Given you a number n, please count the number of coprime in the interval [a, b] and N.
Two number coprime when and only if they have no other public factors other than 1 or their largest public factor is 1. 1 and any number are mutually-voxel.
Input
The first line enters an integer t (1 <= T <= 100), which represents the T-group test data.
Next T line, 3 integers per line a,b,n (1 <= a <=b <=10^15, 1<= n <= 10^9), separated by a space.
Output
Outputs an integer representing the number of n coprime.
Sample Input
2
1 10 2
3 10 5
Sample Output
5
6

Gray-Grey: the idea is the principle of tolerance and repulsion.

1#include <iostream>2#include <cstdio>3#include <cstring>4 using namespacestd; 5 #defineLL Long Long6 #defineMAXN 707   8 LL PRIME[MAXN]; 9ll Make_ans (ll num,intm)Ten {   OneLL ans=0, Tmp,i,j,flag;  A      for(i=1;i< (LL) (1&LT;&LT;M); i++)  -     {   -tmp=1, flag=0;  the          for(j=0; j<m;j++)    -             if(i& (LL) (1<<J ))) -flag++,tmp*=Prime[j];  -         if(flag&1)//principle of tolerance and repulsion +ans+=num/tmp;  -         Else   +ans-=num/tmp;  A     }   at     returnans;  - }   -    - intMain () - {   -     intt,t=0, M;  in LL n,a,b,i;  -scanf"%d",&T);  to      while(t--)   +     {   -scanf"%i64d%i64d%i64d",&a,&b,&N);  them=0;  *          for(i=2; i*i<=n;i++)   $             if(n&&n%i==0)  Panax Notoginseng             {   -prime[m++]=i;  the                  while(n&&n%i==0)   +N/=i;  A             }      the         if(n>1)   +prime[m++]=N;  -printf"%i64d\n", (B-make_ans (B,m))-(A-1-make_ans (A-1, M)));  $     }   $     return 0;  -}

A total of 5 questions, not to be continued ....

acm-Nanjing University Eighth session of the program design Competition-Online race (2016.04.17)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.