题目链接: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. mysql 远程连接

    4.现在如果用你电脑上的终端进行MySQL连接时,有可能出现如下错误: MySQL远程连接ERROR 2003 (HY000):Can't connect to MySQL server on'XXX ...

  2. OCR技术

    "起初我写这篇教程是在情人节,OCR可以带给你一整年的爱". 你之前肯定已经见过,OCR技术被应用于在平板电脑上将扫描文件处理成手写字迹,还被应用于谷歌最近添加到他们的Transl ...

  3. 在ubunut下使用pycharm和eclipse进行python远程调试

    我比较喜欢Pycharm,因为这个是JetBrains公司出的python IDE工具,该公司下的java IDE工具--IDEA,无论从界面还是操作上都甩eclipse几条街,但项目组里有些人使用e ...

  4. JS 职责链模式

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  5. MongoDB 查询 (转) 仅限于C++开发

    1.find MongoDB使用find来进行查询.查询就是返回一个集合中文档的子集,子集合的范围从0个文档到整个集合.find的第一个参数 决定了要返回哪些文档.其形式也是一个文档,说明要查询的细节 ...

  6. Android类参考---Fragment

    Android类参考---Fragment public final boolean isAdded() 如果该Fragment对象被添加到了它的Activity中,那么它返回true,否则返回fal ...

  7. poj1179

    //Accepted 244 KB 0 ms //区间dp //石子合并模型 #include <cstdio> #include <cstring> #include < ...

  8. keil(持续更新)

    1函数格式提示 2  cording时有警告和错误提示 3 类的成员 提示

  9. HttpClient -- 血的教训

    HttpClient -- 血的教训 千万别用httpClient 不支持httpVersion2.0 因为这个导致项目重做

  10. 2016-1-3点菜系统demo的实现,pickerView的学习

    // // ViewController.m // pickView // // Created by Mac on 16/1/3. // Copyright © 2016年 Mac. All rig ...