codeforces 535A-水题;

#include <bits/stdc++.h>
using namespace std;
typedef long long LL; char s2[15][20]={"eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
char s1[15][20]={"ten","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
char s3[15][20]={"one","two","three","four","five","six","seven","eight","nine"}; int main()
{ int n;
scanf("%d",&n);
if(n==0)
{
puts("zero");
return 0;
}
if(n>=10)
{
if(n%10==0)
printf("%s",s1[n/10-1]);
else if((n/10)==1)
printf("%s",s2[n%10-1]);
else
printf("%s-%s",s1[n/10-1],s3[n%10-1]);
}
else
printf("%s",s3[n%10-1]); return 0;
}

codeforces 535B

最多才2^9个数,直接预处理,然后找一遍。

#include <bits/stdc++.h>
using namespace std;
typedef long long LL; LL p[1000000]; LL Pow(int k)
{
LL ans=1;
for(int i=1;i<=k;i++)
ans=ans*10LL;
return ans;
}
int num;
void init()
{ LL k;
p[0]=4LL;
p[1]=7LL;
num=2;
bool flag=false;
for(int i=1;i<=9;i++)
{
int t=0;
k=Pow(i);
for(int j=0;j<num;j++)
{
if(p[j]*10<k) continue;
p[num+t]=k*4LL+p[j];
if(p[num+t]>1000000000)
{
num=num+t;
flag=true;
break;
}
t++;
p[num+t]=k*7LL+p[j];
if(p[num+t]>1000000000)
{
num+=t;
flag=true;
break;
}
t++;
}
if(flag) break;
num=num+t;
}
} int main()
{
init();
LL n;
scanf("%lld",&n);
sort(p,p+num);
for(int i=0;i<num;i++)
{
if(p[i]==n)
{
printf("%d\n",i+1);
return 0;
}
}
return 0;
}

codeforces 535C:题意:

给等差数列:首项A,公差B,n个询问

每个询问 给l,t,m

以l为左端点,每次可以最多选择m个数,使这些数 -1   

t次操作后,求最长序列使所有数为0,输出这个最长序列的右端序号

思路:

二分对吧。

那么就去找二分的满足条件对吧。

首先数列里面最大的数肯定<=t,对勾

数列里面所有的数相加和<=t*m 对勾

然后二分 11111100000型 对勾

#include <cstdio>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long LL;
int n;
LL a,b,t,m; LL sum[1000100];
void init()
{
sum[0]=0;
sum[1]=a;
for(LL i=2;i<=1000000;i=i+1LL)
sum[i]=sum[i-1]+a+(i-1LL)*b;
} int main()
{
LL tmp;
scanf("%I64d%I64d%I64d",&a,&b,&n);
init();
while(n--)
{
scanf("%I64d%I64d%I64d",&tmp,&t,&m);
LL left=tmp,right=1000000;
while(left<right)
{
LL mid=left+(right-left+1LL)/2LL;
if((a+(mid-1LL)*b)<=t&&(sum[mid]-sum[tmp-1])<=t*m)
left=mid;
else
right=mid-1LL;
}
if((a+(left-1LL)*b)<=t&&(sum[left]-sum[tmp-1])<=t*m)
printf("%I64d\n",left);
else
puts("-1");
}
return 0;
}
/*
2 1 4
1 5 3
3 3 10
7 10 2
6 4 8
*/

Codeforces Round #299 (Div. 2)【A,B,C】的更多相关文章

  1. 【CF1256】Codeforces Round #598 (Div. 3) 【思维+贪心+DP】

    https://codeforces.com/contest/1256 A:Payment Without Change[思维] 题意:给你a个价值n的物品和b个价值1的物品,问是否存在取物方案使得价 ...

  2. Codeforces Round #331 (Div. 2)【未完待续】

    http://codeforces.com/problemset/problem/596/B GGGGGGGGGGGGGGGGGGG

  3. Codeforces Round #493 (Div. 2) 【A,B,C】

    简单思维题 #include<bits/stdc++.h> using namespace std; #define int long long #define inf 0x3f3f3f3 ...

  4. Codeforces Round #609 (Div. 2) 【A,B,C】

    题意:给一个n<=1e7,找两个合数a和b使得a-b的差为n. 构造a=3n,b=2n,必含有公因子n,只有当n是1的时候是特例. #include<bits/stdc++.h> u ...

  5. 二分搜索 Codeforces Round #299 (Div. 2) C. Tavas and Karafs

    题目传送门 /* 题意:给定一个数列,求最大的r使得[l,r]的数字能在t次全变为0,每一次可以在m的长度内减1 二分搜索:搜索r,求出sum <= t * m的最大的r 详细解释:http:/ ...

  6. 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas

    题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...

  7. DFS Codeforces Round #299 (Div. 2) B. Tavas and SaDDas

    题目传送门 /* DFS:按照长度来DFS,最后排序 */ #include <cstdio> #include <algorithm> #include <cstrin ...

  8. Codeforces Round #443 (Div. 2) 【A、B、C、D】

    Codeforces Round #443 (Div. 2) codeforces 879 A. Borya's Diagnosis[水题] #include<cstdio> #inclu ...

  9. Codeforces Round #436 (Div. 2)【A、B、C、D、E】

    Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...

随机推荐

  1. linux日志系统介绍 —— syslog(),openlog(),closelog()

    函数使用介绍 这里面的三个函数openlog, syslog.closelog是一套系统日志写入接口.另外那个vsyslog和syslog功能一样,仅仅是參数格式不同.         通常.sysl ...

  2. 【windows】更改最大动态端口数

    最近业务遇到一个奇怪的问题,一台iis服务器,居然报端口不足的错误,分析应该是服务器可用的动态端口数不够了,windows默认的动态端口范围为:1024-5000,也就是最多3977个动态端口可用,如 ...

  3. Git如何强制拉取一个远程分支到本地分支(转载)

    有时候,我们在使用git pull指令想把一个远程分支拉取到本地分支的时候,老是会拉取失败,这一般是因为某种原因,本地分支和远程分支的内容差异无法被git成功识别出来,所以git pull指令什么都不 ...

  4. mysql的安装与基本管理

    MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下公司.MySQL 最流行的关系型数据库管理系统,在 WEB 应用方面MySQL是最好的 RDBMS ...

  5. cinder挂载卷的过程原理

    LVM名称介绍 PV:物理磁盘 VG:卷组,多个PV可以组成一个VG,一个VG可以划分成多个LV(逻辑卷). PP:物理区块,将一个VG逻辑的划分成连续的小块. LP:逻辑区块,若干个PP组成一个LP ...

  6. 在ubuntu怎样修改默认的编码格式

    ubuntu修改系统默认编码的方法是: 1. 参考 /usr/share/i18n/SUPPORTED 编辑/var/lib/locales/supported.d/* gedit /var/lib/ ...

  7. hdu 2015校赛1002 Dual horsetail (思维题 )

    Dual horsetail Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

  8. js动态插入标签代码(insertAdjacentHTML)

    做网页时通过ajax请求获取到数据后,有的需要把数据拼接到带有各种标签的字符串中,拼接完字符串就需要把字符串动态添加到网页上的某个位置,举个

  9. Spring 4.3 的新功能和增强

    转载自https://my.oschina.net/waylau/blog/698186 核心容器改进 核心容器额外提供了更丰富的元数据来改进编程. 默认 Java 8 的方法检测为 bean 属性的 ...

  10. oracle数据库如何备份一张表

    --用户名:tms--创建表ts_dictionary的备份create table ts_dictionary_20160715 as select * from ts_dictionary; 补充 ...