ACM-ICPC 2018 焦作赛区网络预赛
Posted acgoto
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ACM-ICPC 2018 焦作赛区网络预赛相关的知识,希望对你有一定的参考价值。
A-Magic Mirror
Jessie has a magic mirror.
Every morning she will ask the mirror: ‘Mirror mirror tell me, who is the most beautiful girl in the world?‘ If the mirror says her name, she will praise the mirror: ‘Good guy!‘, but if the mirror says the name of another person, she will assail the mirror: ‘Dare you say that again?‘
Today Jessie asks the mirror the same question above, and you are given a series of mirror‘s answers. For each answer, please output Jessie‘s response. You can assume that the uppercase or lowercase letters appearing anywhere in the name will have no influence on the answer. For example, ‘Jessie‘ and ‘jessie‘ represent the same person.
Input
The first line contains an integer T(1≤T≤100), which is the number of test cases.
Each test case contains one line with a single-word name, which contains only English letters. The length of each name is no more than 15.
Output
For each test case, output one line containing the answer.
样例输入
2 Jessie Justin
样例输出
Good guy! Dare you say that again?
解题思路:签道题,把源字符串中的所有大写字母改成小写字母,然后再判断即可。
AC代码:
1 #include<bits/stdc++.h> 2 using namespace std; 3 string str;int t; 4 int main(){ 5 while(cin>>t){ 6 while(t--){ 7 cin>>str; 8 for(int i=0;str[i];++i) 9 if(isupper(str[i]))str[i]+=32; 10 if(str=="jessie")cout<<"Good guy!"<<endl; 11 else cout<<"Dare you say that again?"<<endl; 12 } 13 } 14 return 0; 15 }
G-Give Candies
There are N children in kindergarten. Miss Li bought them N candies. To make the process more interesting, Miss Li comes up with the rule: All the children line up according to their student number (1...N), and each time a child is invited, Miss Li randomly gives him some candies (at least one). The process goes on until there is no candy. Miss Li wants to know how many possible different distribution results are there.
Input
The first line contains an integer T, the number of test case.
The next T lines, each contains an integer N.
1 ≤ T ≤ 100
1 ≤ N ≤ 10^100000
Output
For each test case output the number of possible results (mod 1000000007).
样例输入
1 4
样例输出
8
解题思路:签道题,这道题跟hdu4704一样,题解链接:题解报告:hdu 4704 Sum(整数快速幂+费马小定理)。此题题意为给任意多个小伙伴分糖果,每个人可以得到0﹣n块糖果,求将n分完的方案数。很容易想到隔板法,有n-1个空,每个空可以选择插入或不插入一块隔板,那么一共有2^(n-1)种方案数,由于n很大且取模大质数,因此要用费马小定理来降幂。
AC代码:
1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long LL; 4 const LL mod=1000000007; 5 const int maxn=1e5+5;//N最大有10^5位 6 char str[maxn];int t; 7 LL mod_power(LL a,LL b){//整数快速幂 8 LL ans=1; 9 while(b){ 10 if(b&1)ans=ans*a%mod; 11 a=a*a%mod; 12 b>>=1; 13 } 14 return ans; 15 } 16 int main(){ 17 while(cin>>t){ 18 while(t--){ 19 cin>>str; 20 LL N=0; 21 for(int i=0;str[i]!=‘