Codeforces Round #299 (Div. 2)【A,B,C】
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】的更多相关文章
- 【CF1256】Codeforces Round #598 (Div. 3) 【思维+贪心+DP】
https://codeforces.com/contest/1256 A:Payment Without Change[思维] 题意:给你a个价值n的物品和b个价值1的物品,问是否存在取物方案使得价 ...
- Codeforces Round #331 (Div. 2)【未完待续】
http://codeforces.com/problemset/problem/596/B GGGGGGGGGGGGGGGGGGG
- Codeforces Round #493 (Div. 2) 【A,B,C】
简单思维题 #include<bits/stdc++.h> using namespace std; #define int long long #define inf 0x3f3f3f3 ...
- 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 ...
- 二分搜索 Codeforces Round #299 (Div. 2) C. Tavas and Karafs
题目传送门 /* 题意:给定一个数列,求最大的r使得[l,r]的数字能在t次全变为0,每一次可以在m的长度内减1 二分搜索:搜索r,求出sum <= t * m的最大的r 详细解释:http:/ ...
- 水题 Codeforces Round #299 (Div. 2) A. Tavas and Nafas
题目传送门 /* 很简单的水题,晚上累了,刷刷水题开心一下:) */ #include <bits/stdc++.h> using namespace std; ][] = {" ...
- DFS Codeforces Round #299 (Div. 2) B. Tavas and SaDDas
题目传送门 /* DFS:按照长度来DFS,最后排序 */ #include <cstdio> #include <algorithm> #include <cstrin ...
- Codeforces Round #443 (Div. 2) 【A、B、C、D】
Codeforces Round #443 (Div. 2) codeforces 879 A. Borya's Diagnosis[水题] #include<cstdio> #inclu ...
- Codeforces Round #436 (Div. 2)【A、B、C、D、E】
Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...
随机推荐
- Hadoop-2.2.0中文文档—— MapReduce 下一代--容量调度器
目的 这份文档描写叙述 CapacityScheduler,一个为Hadoop能同意多用户安全地共享一个大集群的插件式调度器,如他们的应用能适时被分配限制的容量. 概述 CapacitySchedul ...
- linux删除目录下所有文件,但是保留文件夹
删除目录和子目录下所有rpm文件,但是保留文件夹,先cd到想要删除的目录 命令如下 find ./ -name "*.rpm" | xargs rm
- Appium移动自动化配置-ios&安卓
官网安装参考:https://www.npmjs.com/package/appium Appium安装 1.安装nodejs 2.安装appium iOS侧环境安装 1.安装xcode 2.安装Xc ...
- iPad actionsjeet
在iphone和ipad上使用UIActionShee控件t的效果会不一样,在苹果的官方文档中有相关说明: 在ipad上使用UIActionSheet控件改控件不再从底部弹出,而是从屏幕中间弹出与UI ...
- 3D特效焦点图
在线演示 本地下载
- 编辑框的WM_MOUSELEAVE和WM_MOUSEHOVER使用
// 参考资料 // http://www.cnblogs.com/weiqubo/archive/2011/04/14/2016323.html 最近工作需要,需要自定义编辑框,改写编辑框CEdit ...
- hihocoder 在线测试 补提交卡 (Google)
题目1 : 补提交卡 时间限制:2000ms 单点时限:1000ms 内存限制:256MB 描述 小Ho给自己定了一个宏伟的目标:连续100天每天坚持在hihoCoder上提交一个程序.100天过去 ...
- ActiveMQ持久化机制
用户注册成功后发短信提醒 同步http 异步mq JMS中两种通讯模式: 发布订阅 一对多 topic 去过消费者集群的话 都会消费 消息队列 点对点 queue 去过消费者集群的话 ...
- C++(一)— stringstream的用法
输入输出的头文件 <iostream> string流的头文件 <sstream> 文件流的头文件 <fstream> 1.利用输入输出做数据转换 stri ...
- Python 连接Oracle数据库
连接:python操作oracle数据库 python——连接Oracle数据库 python模块:cx_Oracle, DBUtil 大概步骤: 1. 下载模块 cx_Oracle (注意版本) ...