博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ZOJ Monthly, October 2010 ABEFI
阅读量:5784 次
发布时间:2019-06-18

本文共 3940 字,大约阅读时间需要 13 分钟。

#include 
#include
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;}
#include 
#include
#include
#include
#include
using namespace std;typedef long long ll;int Rand(int l,int r){ int ans = rand()%r+1; while(ans
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<
<

#include 
#include
#include
#include
#include
#include
#include
#include
/*#include
#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
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;}
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;}
#include 
#include
#include
#include
using namespace std;#define eps (1e-8)const int N = 100005;bool Is0(double x){ return (x>0?x:-x)
=m)break; // last.put(); double t = dis(last, a[i]); if(t

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

你可能感兴趣的文章
H3C-路由策略
查看>>
centos 修改字符界面分辨率
查看>>
LNMP之Mysql主从复制(四)
查看>>
阅读Spring源代码(1)
查看>>
nagios一键安装脚本,nagios监控被监控主机上的应用服务mysql数据库
查看>>
grep 命令
查看>>
JS二维数组的声明和使用
查看>>
v$archive_gap dg dataguard 断档处理 scn恢复
查看>>
问责IT风险管理:CIO需关注两个重点
查看>>
Winform打包发布图解
查看>>
PDF文件怎么编辑,超简单的方法
查看>>
EasyUI基础入门之Easyloader(载入器)
查看>>
Uva 839 Not so Mobile
查看>>
30款超酷的HTTP 404页面未找到错误设计
查看>>
程序猿必备 MyEclipse2013-2014系列
查看>>
在图里, 你看到了什么? 5秒内看到的话, 你很牛
查看>>
java中ArrayList 、LinkList区别
查看>>
Spring ’14 Wave Update: Installing Dynamics CRM on Tablets for Windows 8.1
查看>>
利用rand7()构造rand10()
查看>>
MySQL 备份与恢复
查看>>