map Codeforces Round #Pi (Div. 2) C. Geometric Progression
2015-08-06 21:11
423 查看
题目传送门
/* 题意:问选出3个数成等比数列有多少种选法 map:c1记录是第二个数或第三个数的选法,c2表示所有数字出现的次数。别人的代码很短,思维巧妙 */ /************************************************ * Author :Running_Time * Created Time :2015-8-6 1:07:18 * File Name :C.cpp ************************************************/ #include <cstdio> #include <algorithm> #include <iostream> #include <sstream> #include <cstring> #include <cmath> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <list> #include <map> #include <set> #include <bitset> #include <cstdlib> #include <ctime> using namespace std; #define lson l, mid, rt << 1 #define rson mid + 1, r, rt << 1 | 1 typedef long long ll; const int MAXN = 2e5 + 10; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; map<ll, ll> c1, c2; int main(void) { //Codeforces Round #Pi (Div. 2) C. Geometric Progression ll ans = 0, x; ll n, k; scanf ("%I64d%I64d", &n, &k); for (int i=1; i<=n; ++i) { scanf ("%I64d", &x); if (x % (k * k) == 0) ans += c1[x/k]; //x可选作第三个数 if (x % k == 0) c1[x] += c2[x/k]; //x第三个数或第二个数 c2[x]++; } printf ("%I64d\n", ans); return 0; }
相关文章推荐
- Android 基于蓝牙的方向控制器
- 测试用例设计白皮书--因果图方法
- 树-堆结构练习——合并果子之哈夫曼树 优先队列
- C语言学习资源
- Codeforces Round #Pi (Div. 2)——set——Berland National Library
- 构造 Codeforces Round #Pi (Div. 2) B. Berland National Library
- 测试用例设计白皮书--错误推测方法
- 测试用例设计白皮书--边界值分析方法
- 华为机试训练:图片排序
- poj2253flody变形(最小生成树)
- Ubuntu10.04默认不支持root直接登录
- sql语句逻辑执行顺序
- nginx 作为反向代理实现负载均衡的例子
- 编译支持MFC的pcl::visualization静态库文件
- C++ 获取文件夹下的所有文件名
- 求一个字符串中出现相同且长度最长的字符串
- [MetaHook] Quake FMOD player demo
- 测试用例设计白皮书--等价类划分方法
- 通过PowerShell命令批量启用Lync用户
- Grunt入门教程(自动任务运行器)