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. P4298 [CTSC2008]祭祀

    P4298 [CTSC2008]祭祀 传递闭包跑一遍按联通建图 $(1)$最长反链长度=最小链覆盖=n-最大匹配 $(2)$定义作为最大匹配出现在左端点的集合为$S$,作为最大匹配出现在右端点的集合为 ...

  2. Linux_学习_01_常用命令大全

    一.文件目录 1.列出目录 ls -a #显示隐藏文件 -l #显示文件和目录的详细资料 -h -lrt tree #显示文件和目录由根目录开始的树形结构 lstree #显示文件和目录由根目录开始的 ...

  3. 【Codeforces】Gym 101156G Non-Attacking Queens 打表

    题意 求$n\times n$的棋盘上放$3$个皇后使得互相不攻击的方案数 拓展是$m\times n$棋盘上放$k$皇后,暴力打表找到了公式 OEIS 代码 import java.math.Big ...

  4. linux标准输入输出与重定向

    原文:http://blog.sina.com.cn/s/blog_8333cf8f0100vzzl.html##1 1. 标准输入输出和错误    linux下使用标准输入文件stdin和标准输出文 ...

  5. linux 网络编程getdomainname与gethostname函数

    getdomainname与gethostname函数 1 gethostname() : 返回本地主机的标准主机名. 原型如下: #include <unistd.h> int geth ...

  6. umount 卸载 无响应的 NFS 文件系统

    当NFS Client 无法访问 NFS Server的适合,在Client上df操作等就会挂起. 这个适合需要将挂载的NFS卸载掉.在不知道挂载点的情况下,可以使用nfsstat -m 命令来查看. ...

  7. 【Lintcode】013.strStr

    题目: For a given source string and a target string, you should output the first index(from 0) of targ ...

  8. AtCoder Grand Contest 014 D:Black and White Tree

    题目传送门:https://agc014.contest.atcoder.jp/tasks/agc014_d 题目翻译 给你一棵树,每次任选一个点染色,先手染白色,后手染黑色.如果最后存在一个白色的点 ...

  9. [原创]如何解决IE10下CkEditor报 --- SCRIPT5007: 无法获取未定义或 null 引用的属性“toLowerCase”

    如何解决IE10下CkEditor报 --- SCRIPT5007: 无法获取未定义或 null 引用的属性“toLowerCase” 错误 如果你的IE是IE10,且不是运行在IE的兼容模式你也许会 ...

  10. Python之路:Jquery Ajax的使用

    Ajax概述 Ajax就是通过 HTTP 请求加载远程数据.通常用于定制一些http请求来灵活的完成前端与后端的数据交互需求. 注意,所有的选项都可以通过$.ajaxSetup()函数来全局设置. J ...