多校7题目

GuGuFishtion

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1008    Accepted Submission(s): 175

Problem Description
Today XianYu is too busy with his homework, but the boring GuGu is still disturbing him!!!!!!
At the break time, an evil idea arises in XianYu's mind.
‘Come on, you xxxxxxx little guy.’
‘I will give you a function ϕ(x) which counts the positive integers up to x that are relatively prime to x.’
‘And
now I give you a fishtion, which named GuGu Fishtion, in memory of a
great guy named XianYu and a disturbing and pitiful guy GuGu who will be
cooked without solving my problem in 5 hours.’
‘The given fishtion is defined as follow:

Gu(a,b)=ϕ(ab)ϕ(a)ϕ(b)

And now you, the xxxxxxx little guy, have to solve the problem below given m,n,p.’

(∑a=1m∑b=1nGu(a,b))(modp)

So SMART and KINDHEARTED you are, so could you please help GuGu to solve this problem?
‘GU GU!’ GuGu thanks.

 
Input
Input contains an integer T indicating the number of cases, followed by T lines. Each line contains three integers m,n,p as described above.
1≤T≤3
1≤m,n≤1,000,000
max(m,n)<p≤1,000,000,007
And given p is a prime.
 
Output
Please output exactly T lines and each line contains only one integer representing the answer.
 
Sample Input
1
5 7 23
 
Sample Output
2
 
 
 

Sequence

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 1782    Accepted Submission(s): 377

Problem Description
Let us define a sequence as below

⎧⎩⎨⎪⎪⎪⎪⎪⎪F1F2Fn===ABC⋅Fn−2+D⋅Fn−1+⌊Pn⌋

Your job is simple, for each task, you should output Fn module 109+7.

 
Input
The first line has only one integer T, indicates the number of tasks.

Then, for the next T lines, each line consists of 6 integers, A , B, C, D, P, n.

1≤T≤200≤A,B,C,D≤1091≤P,n≤109

 
Sample Input
2
3 3 2 1 3 5
3 2 2 2 1 4
 
Sample Output
36
24
 
v judge 练习题

A - Round House

Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to n. Entrance n and entrance 1 are adjacent.

Today Vasya got bored and decided to take a walk in the yard. Vasya lives in entrance a and he decided that during his walk he will move around the house b entrances in the direction of increasing numbers (in this order entrance n should be followed by entrance 1). The negative value of b corresponds to moving |b| entrances in the order of decreasing numbers (in this order entrance 1 is followed by entrance n). If b = 0, then Vasya prefers to walk beside his entrance.

Illustration for n = 6, a = 2, b =  - 5.

Help Vasya to determine the number of the entrance, near which he will be at the end of his walk.

Input

The single line of the input contains three space-separated integers n, a and b (1 ≤ n ≤ 100, 1 ≤ a ≤ n,  - 100 ≤ b ≤ 100) — the number of entrances at Vasya's place, the number of his entrance and the length of his walk, respectively.

Output

Print a single integer k (1 ≤ k ≤ n) — the number of the entrance where Vasya will be at the end of his walk.

Examples

Input
6 2 -5
Output
3
Input
5 1 3
Output
4
Input
3 2 7
Output
3

Note

The first example is illustrated by the picture in the statements.

 #include<stdio.h>

 int main()
{
int n;
int a,b;
int ans;
scanf("%d%d %d",&n,&a,&b);
if(b<)
{
int s=b%n;
if(s==) ans=a;
else{
ans=a+(n+(b%n));
if(ans>n)
ans=ans%n;}
}
else if(b==) ans=a;
else
{ ans=a+(b%n);
if(ans>n) ans=ans%n;
}
printf("%d\n",ans);
return ;
}

最新文章

  1. [嵌入式开发]Linux性能分析——上下文切换
  2. html标签思维导图
  3. EXCEL时间日期转换为常规字符显示
  4. atitit.ajax bp dwr 3.的注解方式配置使用流程总结 VO9o.....
  5. 使用Assetbundle时可能遇到的坑
  6. js,css 和 html 分离,见仁见智
  7. JS代码片段
  8. C语言的printf输出格式控制
  9. UVA 1660 Cable TV Network
  10. SolrCloud简介
  11. 最直接的教你OC中Block的简单使用场景
  12. 王爽汇编习题2.2(1):给定地址段为0001H,仅通过变化偏移地址寻址,CPU的寻址范围为____到____
  13. Angular+ionic2 web端 启动程序出现短暂 白屏或黑屏 的处理小妙招
  14. EasyUI中tree,Datagrid,pagenation的使用EasyUI中Datagrid和pagenation进行关联时,再次点击pagenation时让表格数据显示的问题
  15. javascript 变量的引入、变量的声明、变量的初始化
  16. SVN Error:Error performing cleanup for
  17. jQuery实现图片懒加载
  18. django全流程--青空琉璃
  19. Nginx安装echo模块
  20. Spring Data Redis 让 NoSQL 快如闪电 (1)

热门文章

  1. 使用Letsencrypt做SSL certificate
  2. Flask之蓝图的使用
  3. PHP变量定义及工作原理
  4. Spark 加载数据库mysql表中数据进行分析
  5. ACM1004:Let the Balloon Rise
  6. java入门---基本数据类型之内置数据类型
  7. Dinic算法最大流入门
  8. Android stdio build.gradle buildscript 里面的repositories 和allprojects里面 repositories 的区别
  9. tomcat createSecureRandom 花费了将近10分钟
  10. 惊喜Skr人,Istio的创始人Shriram Rajagopalan手把手教你如何使用Istio