卡时技巧(时间卡常技巧)

#include<ctime>
#include<cstdlib>
#include<iostream>
using namespace std;
double t;
const double CLOCKS_PER_SECOND=((clock_t)1000);//定义常量 
void dfs()
{
	cout<<1;
    if(1000*(clock()-t)>=900*CLOCKS_PER_SECOND)//即将超过1000ms时输出答案并结束程序,防止超时 
	{
		/*输出答案*/ 
        exit(0);//退出 
    }else
    dfs();//否则继续搜索 
}
int main(){
    t=clock();//记录开始时间 
    dfs();
    return 0;
}
posted @ 2019-01-31 21:36  lyclyc_NSP  阅读(658)  评论(0编辑  收藏  举报