sgu551 Preparing Problem
题目链接: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的更多相关文章
- 2013/7/17 HNU_训练赛5
sgu 542 Gena vs Petya sgu 543 Cafe 题意:有N组人需要被分配到某些固定了人数的桌子上,其中ai表示第i组有多少个人,安排作为需要符合如下安排:某一组的人员不能够单独在 ...
- NEERC Southern Subregional 2012
NEERC Southern Subregional 2012 Problem B. Chess Championship 题目描述:有两个序列\(a, b\),两个序列都有\(n\)个数,并且这\( ...
- Codeforces Round #306 (Div. 2), problem: (B) Preparing Olympiad【dfs或01枚举】
题意: 给出n个数字,要求在这n个数中选出至少两个数字,使得它们的和在l,r之间,并且最大的与最小的差值要不小于x.n<=15 Problem - 550B - Codeforces 二进制 利 ...
- codeforces B - Preparing Olympiad(dfs或者状态压缩枚举)
B. Preparing Olympiad You have n problems. You have estimated the difficulty of the i-th one as inte ...
- 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 ...
- CF Preparing Olympiad (DFS)
Preparing Olympiad time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Gym 100342H Problem H. Hard Test 构造题,卡迪杰斯特拉
Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...
- hdu 5445 Food Problem 多重背包
Food Problem Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5 ...
- Problem M
Problem Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost ...
随机推荐
- MBProgressHUD.h file not found
MBProgressHUD框架,怎么我导入MBProgressHUD+MJ.h会报错.(即MBProgressHUD+MJ根本不存在),我看其他人的视屏又可以导入 MBProgressHUD.h fi ...
- [USACO精选] 第一章 数值计算
好不容易坑来了传说中的USACO精选,近100题我要是能做完就哈哈哈哈了…继今天学并查集连番受挫之后,决定写一写基础题. #0 负二进制 2014-01-10 其实是想到就会做,不想到就不会做的题,数 ...
- SharePoint表单和工作流 - Nintex篇(五)
博客地址 http://blog.csdn.net/foxdave 接上篇点击打开链接 本篇我们应用Nintex来创建一个简单的工作流. 首先创建一个自定义列表,用于存放请假数据用,我们就叫做Leav ...
- AS的快捷键
Ctrl+Shift+Alt+N 查找类中的方法或变量 Ctrl+P 方法参数提示 Alt+Insert 生成代码(如get,set方法,构造函数等) 删除导入多余的包Ctrl+Alt+o 提取局部变 ...
- 机器翻译(noip2010)
分析:该题是经典的队列题目,直接用队列实现就可以.如果数据范围大一些的话还可hash判重! 这可以说是一道送分的题目,但是还有粗心的学生会在这里失分,主要原因是数组的范围定义的不合适,因为空间足够用, ...
- 《Java7中 下划线的新特性》
//Java7引入了一个新功能:程序员可以在数值中使用下画线,不管是 //整形数值,还是浮点型数值,都可以自由地使用下划线.通过下划线 //分隔,可以更直观的分辨数值中到底有多少位. public c ...
- oracle触发器如何使用2
触发器 是特定事件出现的时候,自动执行的代码块.类似于存储过程,但是用户不能直接调用他们.触发器是许多关系数据库系统都提供的一项技术.在ORACLE系统里,触发器类似过程和函数,都有声明,执行和异常处 ...
- 关于python3 OpenCV的安装和配置
开发环境,win7 32bit, Anaconda3.之前尝试pip安装,但是总是不成功.后来,交流群里面废帝大神让我用conda安装,之后按照conda install --channel http ...
- HDU5546 Ancient Go DFS
点击打开链接 题意:给定一个9*9的棋盘,问黑子能否在下一步将白子围住(四面). 由于数据不大,可以直接将'.'换成'x',用DFS搜索. #include<cstdio> #includ ...
- Tiling Up Blocks_DP
Description Michael The Kid receives an interesting game set from his grandparent as his birthday gi ...