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 ...
随机推荐
- 根据图片Uri获得图片文件
2013-12-17 1. 根据联系人图片Uri获得图片文件并将它显示在ImageView上, 代码如下: Uri uri = Uri.parse("content://com.androi ...
- MySql 性能优化杂记
前一段时间接触MySql 服务器,关于查询忧化方面整理,优化主要唯绕几个工具函数 : show profiling , explain , 索引 , limit 如果上司抱怨服务器查询太慢,这时候 ...
- SelectedRows.CurrentRowSelected 和 DeleteItem
procedure TBMListEh.SetCurrentRowSelected(Value: Boolean); var Index: Integer; Current: TUniBookmark ...
- PHP和.NET通用的加密解密函数类,均使用3DES加解密 .
以下为php代码 <PRE class=PHP name="code"> </PRE><PRE class=PHP name="code&q ...
- 使用AWT组件实现验证码功能
import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics2D ...
- SharePoint 跨域还原网站一则
博客地址:http://blog.csdn.net/foxdave 源端:执行PowerShell命令备份网站集 Backup-SPSite http://server_name/sites/site ...
- 学习LCMapString和LCMapStringEx
LCMapStringEx: http://msdn.microsoft.com/en-us/library/windows/desktop/dd318702(v=vs.85).aspx For a ...
- 【IOS基础知识】NSTimer定时器使用
1.声明 NSTimer *timer; 2.定义 timer = [NSTimerscheduledTimerWithTimeInterval:1.0ftarget:selfsele ...
- 字符串常量演示Demo
public class StringDemo { public static void main(String[] args) { // TODO Auto-generated method stu ...
- Codeforces Round #247 (Div. 2)
A.水题. 遍历字符串对所给的对应数字求和即可. B.简单题. 对5个编号全排列,然后计算每种情况的高兴度,取最大值. C.dp. 设dp[n][is]表示对于k-trees边和等于n时,如果is== ...