A. Factory

题意:给出a,m,第一天的总量为a,需要生产为a%m,第二天的总量为a+a%m,需要生产(a+a%m)%m 计算到哪一天a%m==0为止

自己做的时候,把i开到1000来循环就过了,后来搜题解发现这样过了是运气好

应该这样理解:a大于m的时候没有意义,当a%m重复出现的时候,说明出现了循环,终止计算。

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; int main()
{
int i,sum=,ans=,x,m,flag=;
scanf("%d %d",&x,&m);
for(i=;i<=;i++)
{
sum=x;
ans=x%m;
if(ans==)
{
flag=;
break;
}
x=sum+ans;
// printf("x=%d\n",x);
}
if(flag) printf("Yes\n");
else printf("No\n");
}

补-------------------

B. Valuable Resources

题意:给出n个坐标,求能够覆盖这n个坐标的最小的正方形的面积

将这n个点的坐标排序后,正方形的边长为ans=max(a[n]-a[1],b[n]-b[1])

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; int a[],b[];
long long area; int main()
{
int i,j,n;
long long ans1,ans2;
scanf("%d",&n);
for(i=;i<n;i++)
{
cin>>a[i]>>b[i];
}
sort(a,a+n);
sort(b,b+n); ans1=a[n-]-a[];
ans2=b[n-]-b[];
long long t=max(ans1,ans2);
printf("%I64d\n",t*t);
}

C. Bits

题意:给出n,n对数l,r,找出一个数x使得x满足,l<=x<=r,且转换成二进制之后,构成x的1是最多的。

将l从最低位开始填1,直到>=r为止,这样能够保证组成x的1最多

 #include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<algorithm>
using namespace std; typedef long long LL; int main()
{
int n;
LL l,r;
scanf("%d",&n);
while(n--)
{
scanf("%I64d %I64d",&l,&r);
for(int i=;i<;i++)
if((l|(1LL<<i))<=r) l|=(1LL<<i); printf("%I64d\n",l);
}
}

Codeforces Round #276 (Div. 2)的更多相关文章

  1. Codeforces Round #276 (Div. 1) D. Kindergarten dp

    D. Kindergarten Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/proble ...

  2. Codeforces Round #276 (Div. 1) B. Maximum Value 筛倍数

    B. Maximum Value Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/484/prob ...

  3. Codeforces Round #276 (Div. 1) A. Bits 二进制 贪心

    A. Bits Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/484/problem/A Des ...

  4. Codeforces Round #276 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/485 A题.Factory 模拟.判断是否出现循环,如果出现,肯定不可能. 代码: #include<cstdio> ...

  5. Codeforces Round #276 (Div. 1) E. Sign on Fence (二分答案 主席树 区间合并)

    链接:http://codeforces.com/contest/484/problem/E 题意: 给你n个数的,每个数代表高度: 再给出m个询问,每次询问[l,r]区间内连续w个数的最大的最小值: ...

  6. CF&&CC百套计划4 Codeforces Round #276 (Div. 1) A. Bits

    http://codeforces.com/contest/484/problem/A 题意: 询问[a,b]中二进制位1最多且最小的数 贪心,假设开始每一位都是1 从高位i开始枚举, 如果当前数&g ...

  7. CF&&CC百套计划4 Codeforces Round #276 (Div. 1) E. Sign on Fence

    http://codeforces.com/contest/484/problem/E 题意: 给出n个数,查询最大的在区间[l,r]内,长为w的子区间的最小值 第i棵线段树表示>=i的数 维护 ...

  8. codeforces 484C Strange Sorting Codeforces Round #276 (Div. 1) C

    思路:首先 他是对1到k 元素做一次变换,然后对2到k+1个元素做一次变化....依次做完. 如果我们对1到k个元素做完一次变换后,把整个数组循环左移一个.那么第二次还是对1 到 k个元素做和第一次一 ...

  9. Codeforces Round #276 (Div. 1) E. Sign on Fence 二分+主席树

    E. Sign on Fence   Bizon the Champion has recently finished painting his wood fence. The fence consi ...

随机推荐

  1. linux 全自动提权 exp perl脚本

    linux 全自动提权 exp perl脚本 作者: admin 日期: 2013/01/19发表评论 (0) 查看评论   国外流传过来的 地址 http://dl.packetstormsecur ...

  2. Javascript里的那些距离们

    1.有滚动条的控件的距离: scrollTop和scrollLeft:分别指有滚动条的容器控件的滚动条的top和left:页面滚动条的通用取法:document.body.scrollTop(FF\C ...

  3. POJ 3336 Count the string (KMP+DP,好题)

    参考连接: KMP+DP: http://www.cnblogs.com/yuelingzhi/archive/2011/08/03/2126346.html 另外给出一个没用dp做的:http:// ...

  4. ios图片拉伸两种方法

    UIImage *image = [UIImage imageNamed:@"qq"]; 第一种: // 左端盖宽度 NSInteger leftCapWidth = image. ...

  5. Quant面试准备5本书

    Heard on The Street: Quantitative Questions from Wall Street Job Interviews - Timothy Falcon Crack F ...

  6. SiteView

    http://www.siteview.com/cms/sites/public/home.html

  7. POJ 2653 Pick-up sticks(线段相交)

    题目链接 题意 : 把每根棍往地上扔,找出最后在上面的棍,也就是说找出所有的没有别的棍子压在它的上面的棍子. 思路 : 对于每根棍子,压在他上面的棍子一定是在它之后扔的棍子,所以在找的时候只要找它之后 ...

  8. poj 3159(差分约束经典题)

    题目链接:http://poj.org/problem?id=3159思路:题目意思很简单,都与给定的条件dist[b]-dist[a]<=c,求dist[n]-dist[1]的最大值,显然这是 ...

  9. Java IO(二)

    字节流 字符流: FileReader FileWriter BufferedReader BufferedWriter 字节流: FileInputStream FileOutputStream B ...

  10. 项目中遇到的 linq datatable select

    1如何使用DataTable.Select选出来的Rows生成新的DataTable?DataTable dt = 数据源;DataTable dtt = new DataTable();dtt=dt ...