遇到卡时间比较死的题目的时候可以用
#include
#include
#include
#include
#include
using namespace std;
//适用于正负整形数
template
inline bool scan_d(T &ret)
{
char c; int sgn;
if (c = getchar(), c == EOF) return 0...
分类:
其他好文 时间:
2015-03-15 23:05:30
阅读次数:
166
LL mult_mod(LL a, LL b, LL c){ a %= c; b %= c; LL ret = 0; LL tmp = a; while (b){ if (b & 1){ ret += tmp; if...
分类:
其他好文 时间:
2015-03-15 18:25:38
阅读次数:
164
引:超时设置3种方案1. alarm超时设置方法//代码实现: 这种方式较少用
void sigHandlerForSigAlrm(int signo)
{
return ;
}
signal(SIGALRM, sigHandlerForSigAlrm);
alarm(5);
int ret = read(sockfd, buf, sizeof(buf));
if (ret == -1 ...
分类:
其他好文 时间:
2015-03-14 20:05:16
阅读次数:
184
跟撕纸那个一样。一开始就必胜的特判一下。#include#include#include#includeusing namespace std;int T,n,X[1001],Y[1001],SG[101][101];int sg(int x,int y){ if(SG[x][y]!=-1) ret...
分类:
其他好文 时间:
2015-03-14 12:16:43
阅读次数:
209
类 public class UpLoadFileController : Controller { // // GET: /UpLoadFile/ public ActionResult Index() { ret...
分类:
Web程序 时间:
2015-03-13 12:16:31
阅读次数:
139
判断一个数是不是素数:bool prime(int n){ if(n==0||n==1) return false; if(n==2) return true; for(int i=2;i<=sqrt(n);i++) if(n%i==0) ret...
分类:
其他好文 时间:
2015-03-12 23:49:14
阅读次数:
161
function rgb2hex(rgb) { rgb = rgb.match(/^rgb\((\d+),(\d+),(\d+)\)$/); function hex(x) { return ("0" + parseInt(x).toString(16)).slice(-2); } ret...
分类:
其他好文 时间:
2015-03-12 12:54:58
阅读次数:
124
一个C++版本的State Monad。 需要C++11。 #include template class M> struct Monad { template M ret(A) = 0; template M bind(M, std::function(A)>) = 0;
}; template ...
分类:
编程语言 时间:
2015-03-11 21:31:23
阅读次数:
143
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
int main()
{
const char *ip="127.0.0.1";
int port=12345;
int ret=0;
struc...
分类:
系统相关 时间:
2015-03-11 17:12:39
阅读次数:
197
题意:一块镜子长宽是a*b。现在要调整(切割)成x:y的比例。问调整完的最大面积是多少。思路:先将x,y弄成最简比例,然后放大到不超过min(a,b)即可。代码:ll a,b,x,y;ll gcd(ll a,ll b){ if(b==0) ret a; ret gcd(b,a%b);}i...
分类:
其他好文 时间:
2015-03-11 16:39:18
阅读次数:
116