• CodeForces


    这道题确实是自己太蠢

    每个数通过双倍或者三倍 能否达到同一个数

    当时一直想用LCM/a[i]后来除以2 除以3看最后是否为1 

    然后一直WA On test49

    当然知道是数据爆了 然后就卡住了

    想想如果这n个数能够乘2 乘3 得到同一个数说明 这些数的约数 只在2 和 3的数量上不同 其他约数都应该是相同的

    那么 就按除法 每个数 除以2 除以3 看剩下的约数是否相同 即可

     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <string>
     4 #include <string.h>
     5 #include <map>
     6 #include <fstream>
     7 #include <set>
     8 #define READ() freopen("in.txt", "r", stdin);
     9 using namespace std;
    10 
    11 
    12 long long gcd(long long a, long long b)
    13 {
    14     if (b == 0) return a;
    15     else return gcd(b, a%b);
    16 }
    17 
    18 long long a[100007];
    19 int main()
    20 {
    21     READ()
    22     int n;
    23     set<int> s;
    24     long long LCM, old_LCM, time;
    25     scanf("%d", &n);
    26     for (int i = 0; i < n; i++)
    27     {
    28         scanf("%lld", &a[i]);
    29     }//求得最小公倍数
    30     for (int i = 0; i < n; i++) //判断是否成功
    31     {
    32         while (!(a[i] % 2)) a[i] /= 2;
    33         while (!(a[i] % 3)) a[i] /= 3;
    34         s.insert(a[i]);
    35     }
    36     if (s.size() == 1 ) printf("Yes
    ");
    37     else printf("No
    ");
    38     return 0;
    39 }
  • 相关阅读:
    html5之服务器推送事件
    浅谈js之this对象
    浅谈js之事件处理
    浅谈js之ajax
    浅谈js之事件流
    浅谈js之闭包
    浅谈JS引用类型之Array类型
    关于window.onload的一些小理解
    web渗透测试中WAF绕过讲解(二)基于HTTP协议绕过
    web渗透测试中WAF绕过讲解(一)
  • 原文地址:https://www.cnblogs.com/oscar-cnblogs/p/6435312.html
Copyright © 2020-2023  润新知