2018 CCPC网络赛 Dream&&Find Integer
Posted maybe96
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2018 CCPC网络赛 Dream&&Find Integer相关的知识,希望对你有一定的参考价值。
首先这场比赛打得很难受,因为是第一次打网络赛而且也是比较菜的那种,所以对这场网络赛还是挺期待和紧张的,但是在做题的过程中,主要的压力不是来自于题目,更多的来自于莫干山。。。从12.40-2.00所有的题目都不判了,中间也就写了1003和1004但是都不知道结果就很难受, 然后一直不判就已经没什么看其他题的兴趣了,然后上床休息了一会,直到说杭电的评测机好了,之后才上去继续做题。然后。。一直在写1001和1009。。后面也没有写出来。。直到比赛结束
首先说下1004 签到题竟然写了这么久,而且用了cin超时了一发
Find Integer
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 6597 Accepted Submission(s): 1852
Special Judge
give you two integers n ,a ,you are required to find 2 integers b ,c such that an +bn=cn .
next T lines contains two integers n ,a ;(0≤n≤1000 ,000 ,000,3≤a≤40000)
else print two integers -1 -1 instead.
#include <cstdio> #include <iostream> #include <cmath> #include <map> using namespace std; int main() { long long n; int a; int t; scanf("%d",&t); while(t--) { scanf("%lld %d",&n,&a); if(n>2) printf("-1 -1 "); else if(n==0) printf("-1 -1 "); else if(n==1) printf("1 %d ",a+1); else { if(a==1||a==2) printf("-1 -1 "); else if(a%2==1){ int sum=a*a; printf("%d %d ",sum/2,sum/2+1); } else{ int sum=a*a/2; printf("%d %d ",sum/2-1,sum/2+1); } } } return 0; }
然后是1003
Dream
Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2193 Accepted Submission(s): 805
Special Judge
For instance, (1+4)2=52=25 , but 12+42=17≠25 . Moreover, 9+16−−−−−√=25−−√=5 , which does not equal 3+4=7 .
Fortunately, in some cases when p is a prime, the identity
holds true for every pair of non-negative integers m,n which are less than p , with appropriate definitions of addition and multiplication.
You are required to redefine the rules of addition and multiplication so as to make the beginner‘s dream realized.
Specifically, you need to create your custom addition and multiplication, so that when making calculation with your rules the equation (m+n)p=mp+np is a valid identity for all non-negative integers m,n less than p . Power is defined as
Obviously there exists an extremely simple solution that makes all operation just produce zero. So an extra constraint should be satisfied that there exists an integer q(0<q<p) to make the set {qk|0<k<p,k∈Z} equal to {k|0<k<p,k∈Z} . What‘s more, the set of non-negative integers less than p ought to be closed under the operation of your definitions.
Hint for sample input and output:
From the table we get 0+1=1 , and thus (0+1)2=12=1⋅1=1 . On the other hand, 02=0⋅0=0 , 12=1⋅1=1 , 02+12=0+1=1 .
They are the same.
For every case, there is only one line contains an integer p(p<210) , described in the problem description above. p is guranteed to be a prime.
The j -th(1≤j≤p ) integer of i -th(1≤i≤p ) line denotes the value of (i−1)+(j−1) . The j -th(1≤j≤p ) integer of (p+i) -th(1≤i≤p ) line denotes the value of (i−1)⋅(j−1) .
#include <cstdio> #include <iostream> #include <cmath> #include <map> using namespace std; int main() { long long n,p; int a; int t; scanf("%d",&t); while(t--) { scanf("%lld",&p); for(unsigned long long i=0;i<p;i++){ printf("%lld",i); for(unsigned long long j=1;j<p;j++){ printf(" %lld",(i+j)%p); } printf(" "); } for(unsigned long long i=0;i<p;i++){ printf("0"); for(unsigned long long j=1;j<p;j++){ printf(" %lld",(i*j)%p); } printf(" "); } } return 0; }
以上是关于2018 CCPC网络赛 Dream&&Find Integer的主要内容,如果未能解决你的问题,请参考以下文章
HDU6440 Dream(费马小定理+构造) -2018CCPC网络赛1003