博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
USACO Section 2.1 Ordered Fractions
阅读量:6962 次
发布时间:2019-06-27

本文共 761 字,大约阅读时间需要 2 分钟。

模拟,开始时以为要注意去重,当输出时,判断与前一个是否重复,后来发现没这必要,如果重复了,那后边那组肯定不是互质的

analysis里给出了“super fast solution"的方法,类似杨辉三角,想起了高中时的阿炳老师--两个肩上数之和~~

 

1 /* ID:linyvxi1  2    PROB:frac1  3    LANG:C++  4 */  5 #include 
6 #include
7 using namespace std; 8 typedef struct Frac{
9 int up; 10 int down; 11 }Frac; 12 Frac frac[100000]; 13 int total_solutions=1; 14 bool cmp(Frac a,Frac b) 15 {
16 return ((float)a.up/a.down)<((float)b.up/b.down); 17 } 18 int gcd(int a,int b) 19 {
20 int temp; 21 while(b){
22 temp=a%b; 23 a=b; 24 b=temp; 25 } 26 return a; 27 } 28 void trans(int n) 29 {
30 int i; 31 for(i=1;i

转载于:https://www.cnblogs.com/yangce/archive/2012/02/16/2354562.html

你可能感兴趣的文章
图表(Chart & Graph)你真的用对了吗?
查看>>
做好软件项目验收管理4步走
查看>>
有关dubbo线程池溢出
查看>>
springmvc框架
查看>>
安装Spket插件到Eclipse
查看>>
学习笔记(四)——目录命令、rm 等常用命令、查看文本命令、文件属性
查看>>
Vue知识点整理
查看>>
python笔试题---实践知识点
查看>>
spring boot 2.x data redis 使用也太简单了吧
查看>>
php超时时间说明
查看>>
spring cron表达式及解析过程
查看>>
MyBatis(二)-----注解方式crud
查看>>
navicat连接腾讯云MySQL
查看>>
嵌入式Linux加快物联网开发速度的方案研究
查看>>
java程序员如何拿到2万月薪
查看>>
redis常用命令总结
查看>>
ActiveMQ —— <一> 概述
查看>>
SylixOS内核打印调试方法.
查看>>
加号+和减号-
查看>>
详解Mysql分布式事务XA(跨数据库事务)
查看>>