题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=551

呵呵,题目读的没错,可惜理解错了..==

 #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
int n, t1, t2;
int gcd(int a, int b) {
return b == ? a : (gcd(b, a%b));
}
int exg(int a, int b) {
return a/gcd(a,b)*b;
}
int main(void) {
//freopen("in.txt", "r", stdin);
while (~scanf("%d%d%d", &n, &t1, &t2)) {
int k = exg(t1, t2), s = k/t1 + k/t2, One = n/s, r = n%s, base = One*k,
Min = , cnt = , i, j;
if (t1>t2) swap(t1,t2);
//printf("s = %d r = %d\n", s, r);
if (r)
for (i = , j = ; i+j <= s;) {
if (cnt >= r) break;
if (i * t1 < j * t2) Min=i*t1, i++, cnt++;
else if(i*t1 > j*t2) Min=j*t2, j++, cnt++;
else Min=j*t2, j++, i++, cnt+=;
if (cnt >= r) break;
}
if ( (i-)*t1!=(j-)*t2 && Min == (i-) * t1) cnt++, Min = max(Min, j*t2);
else if ( (i-)*t1!=(j-)*t2 && Min == (j-) * t2) cnt++, Min = max(Min, i*t1);
//printf("cnt = %d\n", cnt);
printf("%d %d\n", cnt+s*One, base+Min);
}
return ;
}

这场比赛就栽在了这道题目上面,从开场到结束前5分钟...

sgu551 Preparing Problem的更多相关文章

  1. 2013/7/17 HNU_训练赛5

    sgu 542 Gena vs Petya sgu 543 Cafe 题意:有N组人需要被分配到某些固定了人数的桌子上,其中ai表示第i组有多少个人,安排作为需要符合如下安排:某一组的人员不能够单独在 ...

  2. NEERC Southern Subregional 2012

    NEERC Southern Subregional 2012 Problem B. Chess Championship 题目描述:有两个序列\(a, b\),两个序列都有\(n\)个数,并且这\( ...

  3. Codeforces Round #306 (Div. 2), problem: (B) Preparing Olympiad【dfs或01枚举】

    题意: 给出n个数字,要求在这n个数中选出至少两个数字,使得它们的和在l,r之间,并且最大的与最小的差值要不小于x.n<=15 Problem - 550B - Codeforces 二进制 利 ...

  4. codeforces B - Preparing Olympiad(dfs或者状态压缩枚举)

    B. Preparing Olympiad You have n problems. You have estimated the difficulty of the i-th one as inte ...

  5. Codeforces Round #306 (Div. 2) B. Preparing Olympiad dfs

    B. Preparing Olympiad Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550 ...

  6. CF Preparing Olympiad (DFS)

    Preparing Olympiad time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. Codeforces Gym 100342H Problem H. Hard Test 构造题,卡迪杰斯特拉

    Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...

  8. hdu 5445 Food Problem 多重背包

    Food Problem Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5 ...

  9. Problem M

    Problem Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost ...

随机推荐

  1. 矩阵(matrix)

    我们定义一个矩阵的权值为这个矩阵四个角上的数值的最小值.现在小M有一个矩阵,他想在这个矩阵中寻找到一个权值最大的子矩阵,请你告诉他这个最大权值.(距形规模最大为2000*2000) 比赛 看到第二题那 ...

  2. NOIP2013 提高组day2 3 华容道 BFS

    描述 小 B 最近迷上了华容道,可是他总是要花很长的时间才能完成一次.于是,他想到用编程来完成华容道:给定一种局面,华容道是否根本就无法完成,如果能完成,最少需要多少时间. 小 B 玩的华容道与经典的 ...

  3. 【STL】-priority_queue的用法

    初始化: priority_queue<int>                           maxPQ; priority_queue<int,vector<int& ...

  4. 父元素与子元素之间的margin-top问题(css hack)(转载)

    情况: 父元素的盒子包含一个子元素盒子,给子元素盒子一个垂直外边距margin-top,父元素盒子也会往下走margin-top的值,而子元素和父元素的边距则没有发生变化. 解决方法: 1.修改父元素 ...

  5. “System.Threading.ThreadAbortException”类型的第一次机会异常在 mscorlib.dll 中发

    问题原因: Thread.Abort 方法 .NET Framework 4  其他版本   1(共 1)对本文的评价是有帮助 - 评价此主题 在调用此方法的线程上引发 ThreadAbortExce ...

  6. Cisco IOS Software Activation Command Reference

    clear license agent : to clear license agent statistics counters or connection statistics (in privil ...

  7. pyqt5 笔记(四)cx_Freeze 实现代码打包exe

    下载地址:https://pypi.python.org/pypi/cx_Freeze 教程:http://www.cnblogs.com/xinzaitian/archive/2010/12/10/ ...

  8. SqlServer DateDiff函数 比较时间 (转)

    DateDiff函数 是一个非常有用的函数,它可以为一些网页做一些特殊的效果.    我就曾用到它和一张'new'字样的图片 来区别网页显示的信息是否为最近的信息.例如:提示最近的通知,最近的新闻等等 ...

  9. iOS 设计模式之工厂模式

    iOS 设计模式之工厂模式 分类: 设计模式2014-02-10 18:05 11020人阅读 评论(2) 收藏 举报 ios设计模式 工厂模式我的理解是:他就是为了创建对象的 创建对象的时候,我们一 ...

  10. java读取大容量excel之二(空格、空值问题)

    最近在项目中发现,对于Excel2007(底层根本是xml) ,使用<java读取大容量excel之一>中的方式读取,若待读取的excel2007文件中某一列是空值,(注意,所谓的空值是什 ...