输入输出挂

http://blog.csdn.net/shahdza/article/details/6317011

inline void in(int &ret){
    char c; ret=0;
    while(c=getchar(),c<‘0‘||c>‘9‘);
    while(c>=‘0‘&&c<=‘9‘) ret=ret*10+(c-‘0‘),c=getchar();
}
inline bool in(int &ret){
    char c; int sgn;
    while(c=getchar(),c!=‘-‘&&(c<‘0‘||c>‘9‘)) if(c==EOF) return 0;
    sgn=(c==‘-‘)?-1:1; ret=(c==‘-‘)?0:(c-‘0‘);
    while(c=getchar(),c>=‘0‘&&c<=‘9‘) ret=ret*10+(c-‘0‘);
    ret*=sgn;
    return 1;
}
inline bool in(double &ret){
    char c; int sgn; double bit=0.1;
    while(c=getchar(),(c<‘0‘||c>‘9‘)&&c!=‘-‘&&c!=‘.‘) if(c==EOF) return 0;
    sgn=(c==‘-‘)?-1:1; ret=(c==‘-‘)?0:(c-‘0‘);
    while(c=getchar(),c>=‘0‘&&c<=‘9‘) ret=ret*10+(c-‘0‘);
    if(c!=‘.‘){ ret*=sgn; return 1; }
    while(c=getchar(),c>=‘0‘&&c<=‘9‘) ret+=(c-‘0‘)*bit,bit/=10;
    ret*=sgn;
    return 1;
}
void out(int x){
    if(x<0){
        putchar(‘-‘); out(-x);
        return;
    }
    if(x>9) out(x/10);
    putchar(x%10+‘0‘);
}
时间: 2024-10-10 12:33:39

输入输出挂的相关文章

POJ1904(有向图缩点+输入输出挂参考)

King's Quest Time Limit: 15000MS   Memory Limit: 65536K Total Submissions: 8311   Accepted: 3017 Case Time Limit: 2000MS Description Once upon a time there lived a king and he had N sons. And there were N beautiful girls in the kingdom and the king k

输入输出挂,手动扩栈。

//#pragma comment(linker, "/STACK:102400000,102400000") c++扩栈 /* int __size__ = 256 << 20;//256 兆 char * __p__ = (char *)malloc(__size__) + __size__; __asm__("movl %0,%%esp\n"::"r"(__p__)); */ /* inline bool scanf_(int

各种各样的输入输出挂!!!

先上C的: 适用于正int的. 1 int read() 2 { 3 char ch=' '; 4 int ans=0; 5 while(ch<'0' || ch>'9') 6 ch=getchar(); 7 while(ch<='9' && ch>='0') 8 { 9 ans=ans*10+ch-'0'; 10 ch=getchar(); 11 } 12 return ans; 13 } 适用于正负int / LL / double 的. (来自 风神) 1 t

Harry Potter and the Forbidden Forest(割边最小的最小割)

Harry Potter and the Forbidden Forest Time Limit:3000MS    Memory Limit:65536KB    64bit IO Format:%I64d & %I64u Description Harry Potter notices some Death Eaters try to slip into Castle. The Death Eaters hide in the most depths of Forbidden Forest.

51nod 1406:与查询

51nod 1406:与查询 题目链接:http://www.51nod.com/onlineJudge/submitDetail.html#!judgeId=222358 题目大意:给出$n$个数,问这$n$个数与$x$做位与($\&$)后值为$x$的有多少个. DP 显然暴力是不行的. 由题目可得,若$a \& x=x$,则$x$的二进制表示中为$1$的位,$a$也必为$1$. 故若$x$和$y$仅有一位不同,且$x\&y=x$,则 与$x$做位与后值为$x$的数中 必包含 与

hdu4812 D Tree 点分治

这里要求输出字典序最小的两个点,就不能像之前那样容斥了,只能直接搞了. 直接搞的话,需要避开n^2,由于这里是等式,显然应该考虑hash映射.从前往后依次枚举计算每棵子树,对于每个子树结点,快速从前面已经计算过的子树中找到答案更新就可以了. 很简单的东西,只是难以用文字解释得清楚.大概一般点分治不用容斥直接搞大多是这样干吧. #pragma comment(linker,"/STACK:102400000,102400000") #include<iostream> #in

MZL&#39;s City(网络流)

MZL's City Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 496    Accepted Submission(s): 164 Problem Description MZL is an active girl who has her own country. Her big country has N cities num

MZL&#39;s endless loop(欧拉回路,欧拉路径)

MZL's endless loop Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 751    Accepted Submission(s): 138 Special Judge Problem Description As we all kown, MZL hates the endless loop deeply, and

14-15西南交通大学ACM新秀杯初赛题解J

Problem A Dull DongGua 撰写:Hacker_vision 题目大意:n个数1,2,3,4--,n;给你每个数的出现次数,判断是否存在这n个数构成的序列满足相邻元素两两互异. 题解: 组合数学中的插空,可以证明只要出现次数最多的那个元素能够剩下所有元素分隔开即可(构成的空能被插满) #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #