SGU 108 Self-numbers 2
来源:互联网 发布:淘宝店铺背景图 编辑:程序博客网 时间:2024/05/01 05:55
sgu你敢不敢把内存搞大点!!!!!
#include<iostream>#include<vector>#include<algorithm>#include<cstdio>#include<queue>#include<stack>#include<string>#include<map>#include<set>#include<cmath>#include<cassert>#include<cstring>#include<iomanip>using namespace std;#ifdef _WIN32#define i64 __int64#define out64 "%I64d\n"#define in64 "%I64d"#else#define i64 long long#define out64 "%lld\n"#define in64 "%lld"#endif#define FOR(i,a,b) for( int i = (a) ; i <= (b) ; i ++)#define FF(i,a) for( int i = 0 ; i < (a) ; i ++)#define FFD(i,a) for( int i = (a)-1 ; i >= 0 ; i --)#define S64(a) scanf(in64,&a)#define SS(a) scanf("%d",&a)#define LL(a) ((a)<<1)#define RR(a) (((a)<<1)+1)#define SZ(a) ((int)a.size())#define PP(n,m,a) puts("---");FF(i,n){FF(j,m)cout << a[i][j] << ' ';puts("");}#define pb push_back#define CL(Q) while(!Q.empty())Q.pop()#define MM(name,what) memset(name,what,sizeof(name))#define read freopen("in.txt","r",stdin)#define write freopen("osr.txt","w",stdout)const int inf = 0x3f3f3f3f;const i64 inf64 = 0x3f3f3f3f3f3f3f3fLL;const double oo = 10e9;const double eps = 10e-10;const double pi = acos(-1.0);struct zz{ int id; int s; bool operator < (const zz & cmp ) const { return s < cmp.s; }}zx;int n,k;int temp;int id;int s[5555];int a[5555];vector<zz>v;bool c1(int x){ return !(x&1);}bool c2(int x){ temp = x; if(x>=11) { x%=11; if(temp<110 && c1(x)) return true; x+=11; if(x<=18) { return c1(x); } return false; } else { return c1(x); }}bool c3(int x){ temp = x; if(x>=101) { x%=101; if(temp < 1010 && c2(x)) return true; x+=101; if(x<=117) { return c2(x); } return false; } else { return c2(x); }}bool c4(int x){ temp = x; if(x>=1001) { x%=1001; if(temp < 10010 && c3(x)) return true; x+=1001; if(x<=1026) { return c3(x); } return false; } else { return c3(x); }}bool c5(int x){ temp = x; if(x>=10001) { x%=10001; if( temp<100010 && c4(x)) return true; x+=10001; if(x<=10035) { return c4(x); } return false; } else { return c4(x); }}bool c6(int x){ temp = x; if( x>= 100001) { x%=100001; if(temp < 1000010 && c5(x)) return true; x += 100001; if(x<=100044) { return c5(x); } return false; } else { return c5(x); }}bool c7(int x){ temp = x; if(x>=1000001) { x%=1000001; if(temp<10000010 && c6(x)) return true; x += 1000001; if(x<=1000053) { return c6(x); } return false; } else { return c6(x); }}int main(){ cin>>n; { int iv=0; v.clear(); cin>>k; for(int i=1;i<=k;i++) { SS(s[i]); zx.s = s[i]; zx.id = i; v.pb(zx); } sort(v.begin(),v.end()); zx.s=-1; zx.id=0; v.push_back(zx); id = 0; for(int i=1;i<=n;i++) { if(!c7(i)) { id++; if(id == v[iv].s) { a[v[iv].id] = i; iv++; while(id == v[iv].s) { a[v[iv].id] = i; iv++; } if(iv == k+1) { break; } } } } cout<<id<<endl; FOR(i,1,k-1) { printf("%d ",a[i]); } printf("%d\n",a[k]); } // system("pause"); return 0;}
- sgu 108-self-numbers 2
- SGU 108 Self-numbers 2
- sgu 108 Self-numbers 2
- sgu 108 self-numbers 2
- sgu 108 Self-numbers 2
- SGU 108 Self-numbers 2(数论)
- SGU 108 Self-numbers II
- 【SGU】108. Self-numbers 2
- SGU 108 Self-numbers 2 (另一种滚动数组)
- [SGU]108. Self-numbers II
- SGU 159 - Self-Replicating Numbers
- SGU 108. Self-numbers 2 离线+位优化
- [SGU 108]Self-numbers II(筛法活用优化+滚动数组)
- 108. Self-numbers 2
- Self-numbers 2
- SGU108 Self-numbers 2
- Self Numbers
- Self Numbers
- 调试freescale CSI sa7113 camera的心得
- SEO笔记——百度排名你需要懂的标题优化
- LL parser
- Android--入门---2---(Android 的环境搭建&配置 JDK 1.6+ Eclipse + ADT +SDK(windows / ubuntu))
- JSpider学习七——调试SpiderImpl的crawl
- SGU 108 Self-numbers 2
- 老鼠喝酒问题(二进制编码的妙用)
- Android--入门---5---(android emulator 介绍)
- freescale R10 ipu lib 分析 - ipu_capture.c
- google map 开发(1)- 新建一个地图及标记
- sdf
- Android--入门---3---(Android 系统的使用&开发前的设置)
- SQL分页查询
- 巴西龟