• 湖南大学ACM程序设计新生杯大赛(同步赛)E


    题目描述

    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

    题解

    规律。

    写了个暴力,算了$1$到$11$的答案,发现只有$1$和$2$有解,所以猜了一发。。

    #include <cstdio>
    #include <algorithm>
    using namespace std;
     
     
    int main() {
      int n;
      scanf("%d", &n);
      if(n == 1 || n == 2) printf("Yes
    ");
      else printf("No
    ");
      return 0;
    }
    

      

  • 相关阅读:
    数组添加元素到特定位置
    jquery $().each,$.each的区别
    JSON字符串 与 JSON对象 互转
    js 获取 url 参数
    js 获取随机数 Math.random()
    js中的|| 与 &&
    js立即执行函数
    css 蒙层
    css 多行文本的溢出显示省略号(移动端)
    移动端利用-webkit-box水平垂直居中(旧弹性盒)
  • 原文地址:https://www.cnblogs.com/zufezzt/p/8099033.html
Copyright © 2020-2023  润新知