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. Unix和Linux历史文化

    1.显示工作目录pwd   print working directory     print name of current/working directory 2.显示自己终端名称tty   pr ...

  2. rails debug

    =debug @thesis config下配置 东西需要重启之后才管用

  3. iOS SDK:iOS调试技巧

    感谢原创 在程序中,无论是你想弄清楚为什么数组中有3个对象而不是5个,或者为什么一个新的玩家开始之后,游戏在倒退——调试在这些处理过程中是比较重要的一部分.通过本文的学习,我们将知道在程序中,可以使用 ...

  4. ActiveMQ之点对点使用

    package com.toov5.producer; import javax.jms.Connection; import javax.jms.JMSException; import javax ...

  5. haproxy 官方文档查看

    http://cbonte.github.io/haproxy-dconv/1.5/configuration.html#reqrep http://www.ttlsa.com/linux/hapro ...

  6. matlab的数组

    1.定义:同一类型的元素的集合. 2.生成:用[]创建,元素之间用逗号或者空格隔开. 第一例: >>a=[1,2,3,4] a = 1 2 3 4 注意,取矩阵的某几列,是这样a(:,2: ...

  7. jQuery 中的常用函数

    on() : 方法在被选元素及子元素上添加一个或多个事件处理程序.自1.7 版本起,on()方法是 bind(),live() 和 delegate()方法的替代品 语法: $(selector).o ...

  8. the art of seo(chapter ten)

    Mobile, Local, and Vertical SEO ***The Mobile Landscape***Mobile site speed:• Google Page Speed Insi ...

  9. listen 70

    Better Sidewalks Could Bring Improved Public Health Most of our serious illnesses and deaths in the ...

  10. Unity-2017.2官方实例教程Roll-a-ball(一)

    声明: 本文系转载,由于Unity版本不同,文中有一些小的改动,原文地址:http://www.jianshu.com/p/6e4b0435e30e Unity-2017.2官方实例教程Roll-a- ...