POJ - 3090 gcd水题
大概题意就是求\(1 \le i,j \le n\)的\(gcd(i,j) = 1\)的个数+2(对于0的特判)
正解应该是欧拉函数或者高逼格的莫比乌斯反演
但数据实在太水直接打表算了
/*H E A D*/
bool GCD[1002][1002];
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main(){
rep(i,1,1000) rep(j,1,1000) GCD[i][j]=bool(gcd(i,j)==1);
int T=read(),kase=0;
while(T--){
int n=read();
if(n==1){
printf("%d %d 3\n",++kase,n);
continue;
}
int ans=0;
rep(i,1,n) rep(j,1,n) ans+=GCD[i][j];
ans+=2;
printf("%d %d %d\n",++kase,n,ans);
}
return 0;
}
POJ - 3090 gcd水题的更多相关文章
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- poj 3264 RMQ 水题
题意:找到一段数字里最大值和最小值的差 水题 #include<cstdio> #include<iostream> #include<algorithm> #in ...
- Poj 1552 Doubles(水题)
一.Description As part of an arithmetic competency program, your students will be given randomly gene ...
- 最小费用最大流模板 poj 2159 模板水题
Going Home Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15944 Accepted: 8167 Descr ...
- POJ 1837 Balance 水题, DP 难度:0
题目 http://poj.org/problem?id=1837 题意 单组数据,有一根杠杆,有R个钩子,其位置hi为整数且属于[-15,15],有C个重物,其质量wi为整数且属于[1,25],重物 ...
- codeforces 664A A. Complicated GCD(水题)
题目链接: A. Complicated GCD time limit per test 1 second memory limit per test 256 megabytes input stan ...
- POJ 1654 Area(水题)
题目链接 卡了一下精度和内存. #include <cstdio> #include <cstring> #include <string> #include &l ...
- POJ 3080 (字符串水题) Blue Jeans
题意: 找出这些串中最长的公共子串(长度≥3),如果长度相同输出字典序最小的那个. 分析: 用库函数strstr直接查找就好了,用KMP反而是杀鸡用牛刀. #include <cstdio> ...
- POJ 2365 Rope(水题)
[题意简述]:给出我们钉子个数与半径,让我们求出缠绕在钉子上的绳子有多长. [分析]:从题目中我们能够看出,绳子长度的和等于每两个钉子的距离的和加上接触在钉子上的绳子的长度,不难发现这部分长度事实上就 ...
随机推荐
- 70个HR面试题
请你自我介绍一下你自己, 回答提示:一般人回答这个问题过于平常,只说姓名.年龄.爱好.工作经验,这些在简历上都有,其实,企业最希望知道的是求职者能否胜任工作,包括:最强的技能.最深入研究的知 ...
- cv 验证
This is how I have trained a xgboost classifier with a 5-fold cross-validation to optimize the F1 sc ...
- 单元测试NUnit 的文章
请参考 https://www.cnblogs.com/ranh941/p/7629279.htmlhttps://blog.csdn.net/qincode/article/details/1831 ...
- HDU 4081 Peach Blossom Spring (最小生成树+dfs)
题意:给定一个 n 个点和相应的权值,要求你用 n-1 条边连接起来,其中一条边是魔法边,不用任何费用,其他的边是长度,求该魔法边的两端的权值与其他边费用的尽量大. 析:先求出最小生成树,然后再枚举每 ...
- Ubuntu普通用户使用串口设备
将普通用户加入dialout组,然后重启或注销登录 sudo gpasswd --add username dialout
- .net 特性 Attribute
public sealed class RemarkAttribute : Attribute { public string Remark { get; set; } // 构造函数 public ...
- window7 Oracle卸载步骤
完全卸载oracle11g步骤:1. 开始->设置->控制面板->管理工具->服务(或 运行 services.msc) 停止所有Oracle服务.2. 开始->程序-& ...
- post get 方法
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.N ...
- 人力资源管理 winform C#
主旨思想:数据库(增,删,改,查) 资源管理器目的:实现基本人员信息 存储,调用,查看头像,修改内容. 注意事项: 1.建立两个表格 (人员表(cold,name,bumen,phone,t ...
- Unity3D管网分析
给大家分享一下自己之前没事写的Unity3D的插件,主要用来对管网的搭建和分析, 开源在Github上 https://github.com/LizhuWeng/PipeNet,可以给需要的朋友做一个 ...