ZOJ 3406 Another Very Easy Task

#include <cstdio>
#include <cstring>
const int N = 100005;
char s[N];
int main() {
bool f = 0;
int size = 0;
char ch;
while(scanf("%c", &ch)!=EOF) {
if( !(ch >= 'a' && ch <='z') && !(ch >='A' && ch <= 'Z')) {
if(size <= 2) {
s[size] = '\0';
printf("%s", s);
} else {
printf("%c%d%c", s[0], size-2, s[size-1]);
}
size = 0;
printf("%c", ch);
} else {
s[size++] = ch;
}
}
return 0;
}
ZOJ 3407 Doraemon's Cake Machine
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
int Rand(int l,int r){
int ans = rand()%r+1;
while(ans<l) ans = rand()%r+1;
return ans;
}
int main() {
// freopen("b.txt","w+",stdout);
int T;
scanf("%d", &T);
ll n, m;
while(T -- > 0) {
cin >> n >> m;
// n = Rand(1,6000000), m = Rand(0,10000);
if(m == 0) {
if(n == 1) puts("0");
else puts("-1");
continue;
}
if(m >= n) {
puts("-1");
}else {
ll d = 2 * (n-m) - 1;
ll ans = -1;
ans = 2 * m - n;// shu
if(ans < 0) ans = -1;
if(n==m+1)ans = 0; // heng
for(ll i = 1; i * i <= d; i += 2) {
if( d % i == 0 ) {
ll a = (i + 1) / 2;
ll b = (d / i - 1) / 2;
ll c = m - a - b;
if(c < 0) continue;
if(ans == -1 || ans>c ){
// printf("%I64d %I64d %I64d %I64d\n", d, a, b, c);
ans = c;
}
}
}
cout<<ans<<endl;
}
}
return 0;
}

problemCode=3410">ZOJ 3410

Layton's Escape
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <iostream>
#include <algorithm>
/*
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0); using namespace std; int main() {
return 0;
}
*/
typedef long long ll;
const ll Inf = (ll)(1e15);
const int N = 25000 + 10;
const int M = 5000 + 10;
struct node {
int cos, lim;
}; node a[N];
ll d[2][M];
std::priority_queue<int> Q; bool cmp(const node& i, const node& j) {
return i.lim < j.lim;
} int main() {
int n, K, cnt;
while (~scanf("%d%d", &n, &K)) {
for (int i = 0; i < n; ++i)
scanf("%d%d", &a[i].cos, &a[i].lim);
std::sort(a, a + n, cmp);
while (!Q.empty())
Q.pop();
cnt = 0;
ll sum = 0;
for (int i = 0; i < n; ++i) {
sum += a[i].cos;
Q.push(a[i].cos);
while (sum > a[i].lim && !Q.empty()) {
sum -= Q.top();
++cnt;
Q.pop();
}
if (sum > a[i].lim || cnt >= K) {
cnt = -1;
break;
}
} printf("%d\n", cnt);
}
return 0;
}
ZOJ 3411 Special Special Judge
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.Scanner; public class Main {
BigInteger gcd(BigInteger a, BigInteger b) {
BigInteger tmp;
while(a.equals(BigInteger.ZERO)==false){
b = b.mod(a);
tmp = b;
b = a;
a = tmp;
}
return b;
} public void work() {
int n, m, a, b, x;
BigInteger[][] d = new BigInteger[55][55];
BigInteger up, down, v; while (cin.hasNext()) {
n = cin.nextInt();
m = cin.nextInt();
a = cin.nextInt();
b = cin.nextInt();
v = BigInteger.valueOf(b - a + 1);
for (int i = 0; i <= n; ++i)
for (int j = 0; j <= m; ++j)
d[i][j] = BigInteger.ZERO;
d[0][0] = BigInteger.ONE;
for (int i = 0; i < n; ++i) {
x = cin.nextInt();
for (int j = 0; j <= m; ++j)
if (d[i][j].compareTo(BigInteger.ZERO) > 0)
for (int z = a; z <= b; ++z)
if (Math.abs(x - z) + j <= m) {
d[i + 1][Math.abs(x - z) + j] = d[i + 1][Math
.abs(x - z) + j].add(d[i][j]);
}
}
up = BigInteger.ZERO;
for (int i = 0; i <= m; ++i)
up = up.add(d[n][i]);
down = BigInteger.ONE;
for (int i = 1; i <= n; ++i)
down = down.multiply(v);
v = gcd(up, down);
up = up.divide(v);
down = down.divide(v);
out.println(up + "/" + down);
}
out.close();
} Main() {
cin = new Scanner(System.in);
out = new PrintWriter(System.out);
} public static void main(String[] args) {
Main e = new Main();
e.work();
} public Scanner cin;
public PrintWriter out; }

problemCode=3414">ZOJ 3414

Trail Walk

problemCode=3414">

#include <cstdio>
#include <cstring>
#include <math.h>
#include <iostream>
using namespace std;
#define eps (1e-8)
const int N = 100005;
bool Is0(double x){
return (x>0?x:-x)<eps;
}
struct node{
double x,y;
void put(){
printf("(%.3f, %.3f)\n",x,y);
}
}a[N], last;
double dis(node aa,node bb){
return sqrt((aa.x-bb.x)*(aa.x-bb.x)+(aa.y-bb.y)*(aa.y-bb.y));
}
int n,m;
int main() {
int i,j,Cas = 1;
while(~scanf("%d %d",&n,&m)) {
m++;
printf("Route %d\n",Cas++);
a[0].x=a[0].y=0;
double len = 0;
for(i=1;i<=n;i++) {
scanf("%lf %lf",&a[i].x,&a[i].y);
len += dis(a[i],a[i-1]);
}
double now = len/(double)m;
// cout<<"len:"<<len<<"now: "<<now<<endl;
int num = 1;
last = a[0];
for(i = 1; i <= n; i++) {
if(num>=m)break;
// last.put();
double t = dis(last, a[i]);
if(t<now && !Is0(t-now)) {
// puts("1");
now -= t;
last = a[i];
continue;
}
else if(Is0(t-now))
{
// puts("2");
printf("CP%d: ",num++);
last = a[i];
now = len/(double)m;
a[i].put();
}
else {
// puts("3");
printf("CP%d: ",num++);
double b = now/t;
double x = a[i].x-last.x, y = a[i].y-last.y;
node tmp = last;
tmp.x += b*x; tmp.y += b*y; tmp.put();
last = tmp;
now = len/(double)m;
i--;
}
}
}
return 0;
}
/*
5.8863495173726744416200360616723
1.4715873793431686104050090154181 */

版权声明:本文博主原创文章。博客,未经同意不得转载。

ZOJ Monthly, October 2010 ABEFI的更多相关文章

  1. ZOJ 3913 Bob wants to pour water ZOJ Monthly, October 2015 - H

    Bob wants to pour water Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge There i ...

  2. ZOJ 3911 Prime Query ZOJ Monthly, October 2015 - I

    Prime Query Time Limit: 1 Second      Memory Limit: 196608 KB You are given a simple task. Given a s ...

  3. ZOJ 3910 Market ZOJ Monthly, October 2015 - H

    Market Time Limit: 2 Seconds      Memory Limit: 65536 KB There's a fruit market in Byteland. The sal ...

  4. ZOJ 3908 Number Game ZOJ Monthly, October 2015 - F

    Number Game Time Limit: 2 Seconds      Memory Limit: 65536 KB The bored Bob is playing a number game ...

  5. ZOJ 3905 Cake ZOJ Monthly, October 2015 - C

    Cake Time Limit: 4 Seconds      Memory Limit: 65536 KB Alice and Bob like eating cake very much. One ...

  6. ZOJ 3903 Ant ZOJ Monthly, October 2015 - A

    Ant Time Limit: 1 Second      Memory Limit: 32768 KB There is an ant named Alice. Alice likes going ...

  7. 143 - ZOJ Monthly, October 2015 I Prime Query 线段树

    Prime Query Time Limit: 1 Second      Memory Limit: 196608 KB You are given a simple task. Given a s ...

  8. 浙大月赛ZOJ Monthly, August 2014

    Abs Problem Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Alice and Bob is playing a ga ...

  9. ZOJ 4010 Neighboring Characters(ZOJ Monthly, March 2018 Problem G,字符串匹配)

    题目链接  ZOJ Monthly, March 2018 Problem G 题意  给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种 ...

随机推荐

  1. HDU 3488Tour(流的最小费用网络流)

    职务地址:hdu3488 这题跟上题基本差点儿相同啊... . 详情请戳这里. 另外我认为有要改变下代码风格了..最终知道了为什么大牛们的代码的变量名都命名的那么长..我决定还是把源点与汇点改成sou ...

  2. VSTO之旅系列(二):创建Excel解决方案

    原文:VSTO之旅系列(二):创建Excel解决方案 本专题概要 引言 创建VSTO项目 Excel对象模型 创建Excel外接程序 创建Excel文档级自定义项 小结 一.引言 也许很多朋友都没有听 ...

  3. android动画-动画分类及代码演示样例

    原来一直对动画一知半解,仅仅知道依照网上的方法会用即可了,可是自己写起来感觉确实有点费劲,今天最终研究了代码实现,一下子感觉清晰多了.先把总结例如以下,代码中有具体的凝视. 动画分类 1.Peoper ...

  4. Python用Tkinter的Frame实现眼睛护士的倒计时黑色屏幕

    import Tkinter,time class MyFrame(Tkinter.Frame): def __init__(self): Tkinter.Frame.__init__(self) s ...

  5. 《Cocos2d-x实战(卷Ⅰ):C++开发》

    <Cocos2d-x实战(卷Ⅰ):C++开发>   基础篇 第1章    准备开始 1.1   本书学习路线图 1.2   使用实例代码   第2章    Cocos2d-x介绍与环境搭建 ...

  6. c++构造函数隐式转换--转换构造函数

    其实我们已经在C/C++中见到过多次标准类型数据间的转换方式了,这种形式用于在程序中将一种指定的数据转换成另一指定的类型,也即是强制转换,比如:int a = int(1.23),其作用是将1.23转 ...

  7. hdu1025 Constructing Roads In JGShining&#39;s Kingdom (nlogn的LIS)

    题目链接 第一次写nlogn复杂度的LIS,纪念一下. 题目意思是说.有两条平行线.两条平行线都有n个城市,都是从左到右标记为1--n,一条线上是富有城市,一个是贫穷城市.输入n.接下来有n行,p,r ...

  8. vim ctl+v批量添加/删除

    vim编辑器---批量注释与反注释 在使用vim编写代码的时候,经常需要用到批量注释与反注释一段代码.下面简要介绍其操作. 方法一 块选择模式 插入注释: 用v进入virtual模式 用上下键选中需要 ...

  9. cocos2d-x3.0 实现HTTP请求GET、POST

    HTTP请求实现 把以下代码拷贝到新创建的project中就能看到效果 HelloWorldScene.h #include "cocos2d.h" /*记得要引头文件*/ #in ...

  10. ECLIPSE JSP TOMCAT 环境搭建

    ECLIPSE JSP TOMCAT 环境搭建(完整) 要学习一门语言,首先要做的就是搭建环境,然后能写一个小的Demo(类似Helloworld),不仅可以建立信心,而且还可以为之后的学习搭建一个验 ...