湖南大学ACM程序设计新生杯大赛(同步赛)E-Permutation【打表+规律】
2017-12-24 18:39
363 查看
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
A mod-dot product between two arrays with length n produce a new array with length n. If array A is a1,a2,…,an and array B is b1,b2,…bn, then A mod-dot B produce an array C c1,c2,…,cn such that c1 = a1*b1%n, c2 = a2*b2%n,…,ci = ai*bi%n,…, cn = an*bn%n.
i.e. A = [2,3,4] and B = [5,2,2] then A mod-dot B = [1,0,2].
A permutation of n is an array with length n and every number from 0 to n-1 appears in the array by exactly one time.
i.e. A = [2,0,1] is a permutation of 3, and B = [3,4,1,2,0] is a permutation of 5, but C = [1,2,2,3] is NOT a permutation of 4.
Now comes the problem: Are there two permutaion of n such that their mod-dot product is also a permutation of n?
输入描述:
The only line with the number n (1 <= n <= 1000)
输出描述:
If there are such two permutation of n that their mod-dot product is also a permutation of n, print “Yes” (without the quote). Otherwise print “No” (without the quote).
示例1
输入
2
输出
Yes
说明
A = [0,1] and B = [0,1]. Then A mod-dot B = [0,1]
示例2
输入
997
输出
No
备注:
1 <= n <= 1000
分析:当时暴力打了个10个的表。然后莽了一发。
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
A mod-dot product between two arrays with length n produce a new array with length n. If array A is a1,a2,…,an and array B is b1,b2,…bn, then A mod-dot B produce an array C c1,c2,…,cn such that c1 = a1*b1%n, c2 = a2*b2%n,…,ci = ai*bi%n,…, cn = an*bn%n.
i.e. A = [2,3,4] and B = [5,2,2] then A mod-dot B = [1,0,2].
A permutation of n is an array with length n and every number from 0 to n-1 appears in the array by exactly one time.
i.e. A = [2,0,1] is a permutation of 3, and B = [3,4,1,2,0] is a permutation of 5, but C = [1,2,2,3] is NOT a permutation of 4.
Now comes the problem: Are there two permutaion of n such that their mod-dot product is also a permutation of n?
输入描述:
The only line with the number n (1 <= n <= 1000)
输出描述:
If there are such two permutation of n that their mod-dot product is also a permutation of n, print “Yes” (without the quote). Otherwise print “No” (without the quote).
示例1
输入
2
输出
Yes
说明
A = [0,1] and B = [0,1]. Then A mod-dot B = [0,1]
示例2
输入
997
输出
No
备注:
1 <= n <= 1000
分析:当时暴力打了个10个的表。然后莽了一发。
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #define ll long long int using namespace std; const int maxn = 1e6 + 10; const ll mod = 1e8 + 7; int a[maxn]; int main() { int n; scanf("%d", &n); if (n == 1 || n == 2) printf("Yes\n"); else printf("No\n"); return 0; }
相关文章推荐
- 湖南大学ACM程序设计新生杯大赛(同步赛) D -Number 【打表+暴力】
- 湖南大学ACM程序设计新生杯大赛(同步赛)E - Permutation
- 湖南大学ACM程序设计新生杯大赛(同步赛)L-Liao Han【打表规律+二分】
- 湖南大学ACM程序设计新生杯大赛(同步赛)L-Liao Han【打表规律+二分】
- 湖南大学ACM程序设计新生杯大赛(同步赛)A-Array 【证明+暴力】
- 湖南大学ACM程序设计新生杯大赛(同步赛)C - Do you like Banana ?
- 湖南大学ACM程序设计新生杯大赛(同步赛)C-Do you like Banana ? 【几何】
- 湖南大学ACM程序设计新生杯大赛(同步赛)G - The heap of socks
- 湖南大学ACM程序设计新生杯大赛(同步赛)G-The heap of socks【排序】
- 湖南大学ACM程序设计新生杯大赛(同步赛)B - Build
- 湖南大学ACM程序设计新生杯大赛(同步赛)J - Piglet treasure hunt Series 2
- 湖南大学ACM程序设计新生杯大赛(同步赛) I-Piglet treasure hunt Series 1【BFS】
- 湖南大学ACM程序设计新生杯大赛(同步赛) I-Piglet treasure hunt Series 1【BFS】
- 湖南大学ACM程序设计新生杯大赛(同步赛)A - Array
- 湖南大学ACM程序设计新生杯大赛 - A Array
- 湖南大学ACM程序设计新生杯大赛(同步赛)H - Yuanyuan Long and His Ballons
- 湖南大学ACM程序设计新生杯大赛 - B Build
- 湖南大学ACM程序设计新生杯大赛(同步赛)D - Number
- 2017湖南大学ACM程序设计新生杯大赛 - B - Build (并查集&&贪心)
- 湖南大学ACM程序设计新生杯大赛 - E Permutation (匈牙利算法)