Topcoder SRM 668 DIV 2
2015-09-16 12:22
309 查看
VerySecureEncryption 模拟
题意:
给你个串message,然后一个置换key,输出置换K次后的结果。题解:
直接模拟就好。代码:
#include<iostream> #include<map> #include<algorithm> using namespace std; typedef long long ll; int ma[1000006]; ll gcd(ll a,ll b) { return b == 0 ? a : gcd(b, a % b); } class AnArray { public: int solveProblem(vector<int> A, int K) { for (auto a:A) { for (int i = 1; i * i <= a; i++) { if (a % i == 0) { ma[i]++; int t = a / i; if (i * i != a && t <= 1000000)ma[t]++; } } } ll res = 0; for (int i = 0; i < A.size(); i++) for (int j = 0; j < A.size(); j++) { if (i == j)continue; ll tmp = 1; tmp = tmp * A[i] * A[j]; int g = gcd(tmp, K); int t = K / g; res = res + ma[K / g]; if (A[i] % t == 0)res--; if (A[j] % t == 0)res--; } return res / 6; } };
View Code
相关文章推荐
- 万能的自动化测试框架----之教育类网站篇
- Linux crontab 定时任务Demo
- linux less从后向前查看日志信息
- linux 查看文件内容的命令
- linux配置java环境变量详细过程
- Linux系统日志分析的基本教程
- shell基础
- Hadoop Streaming 实战: 输出文件分割
- CentOS,清理缓存(drop_caches)
- 启动时运行 Chkdsk “Cannot Open Volume for Direct Access”错误信息
- shell脚本中的awk脚本语法
- 辨别 ShopEX Ecshop
- Ubuntu安装jdk报错:-bash /usr/.../java:No such file or directroy
- Linux下的进程状态
- Magic of David Copperfield II(奇偶性)
- 用python和shell检测centos版本
- 如何给你的网站接入支付宝?
- hadoop学习过程中一系列问题
- 使用ssh访问防火墙后的Linux服务器的方法
- Hadoop YARN如何调度内存和CPU