iscsi

misinter2

Jan 8th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.79 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <sstream>
  4. #include <string>
  5. #include <vector>
  6. #include <queue>
  7. #include <set>
  8. #include <map>
  9. #include <cstdio>
  10. #include <cstdlib>
  11. #include <cctype>
  12. #include <cmath>
  13. #include <cstring>
  14. #include <ctime>
  15. #include <cassert>
  16. using namespace std;
  17. typedef unsigned long long LL;
  18. #define FOR(k,a,b) for(LL k(a); k < (b); ++k)
  19. #define FORD(k,a,b) for(int k(b-1); k >= (a); --k)
  20. #define REP(k,a) for(int k=0; k < (a); ++k)
  21. #define ABS(a) ((a)>0?(a):-(a))
  22. #ifdef HOME
  23. #include "debug.h"
  24. #else
  25. #define debug(args...)
  26. #endif
  27.  
  28. void print_factor(int a)
  29. {
  30.     bool started=false;
  31.     for(int i=2;i*i<=a;++i)
  32.     {
  33.         while(!(a%i))
  34.         {
  35.             if(started)
  36.                 cerr << "*" << i ;
  37.             else
  38.                 cerr << i;
  39.             a/=i;
  40.             started=true;
  41.         }
  42.     }
  43.     if(a>1)
  44.     {
  45.         if(started)
  46.             cerr << "*" << a ;
  47.         else
  48.             cerr << a;
  49.     }
  50. }
  51.  
  52. bool is_prime(int a)
  53. {
  54.     for(int i=2;i*i<=a;++i)
  55.     {
  56.         if(!(a%i))
  57.         {
  58.             return false;
  59.         }
  60.     }
  61.     return true;
  62. }
  63.  
  64. int main()
  65. {    
  66. #ifdef HOME
  67.     clock_t start=clock();
  68.     freopen ("in.txt","r",stdin);
  69.     freopen ("out.txt","w",stdout);
  70.     freopen ("out_err.txt","w",stderr);
  71. #endif
  72.     int T,N;
  73.     scanf("%d",&T);
  74.     const int nmax=100005;
  75.     const int as=26;
  76.     const LL mod=1e9+7;
  77.     vector<bool> used(nmax);
  78.     list<int> l;
  79.     N=0;
  80.     map<int,int> m;
  81.     map<pair<int,int>,vector<int> > m2;
  82.     T=600;
  83.     REP(testcase,T)
  84.     {
  85.         //scanf("%d",&N);
  86.         m.clear();
  87.         N+=2;
  88.         used.clear();
  89.         used.resize(N);
  90.         LL res=1;
  91.         cerr << "--------------------\n" ;
  92.         cerr << "N:" << N << "=";
  93.         print_factor(N);
  94.         cerr << endl;
  95.         REP(i,N)
  96.         {
  97.             if(!used[i])
  98.             {
  99.                 l.clear();
  100.                 res*=as;
  101.                 res%=mod;
  102.                 int act=i%2?i/2:N/2+i/2;
  103.                 used[act]=true;
  104.                 if((act+1)%2)
  105.                     l.push_back(act+1);
  106.                 else
  107.                     l.push_back(act+1);
  108.                 while(act!=i)
  109.                 {
  110.                     act=act%2?act/2:N/2+act/2;
  111.                     if((act+1)%2)
  112.                         l.push_back(act+1);
  113.                     else
  114.                         l.push_back(act+1);
  115.                     used[act]=true;
  116.                 }
  117.                 m[l.size()]++;
  118.                 debug(l);
  119.             }
  120.         }
  121.         map<int,int>::iterator it=m.begin();
  122.         printf("--------------------\n");
  123.         printf("N:%d\n",N);
  124.         for(;it!=m.end();++it)
  125.         {
  126.             printf("%d : %d db\n",it->first,it->second);
  127.             m2[make_pair(it->first,it->second)].push_back(N);
  128.         }
  129.         printf("--------------------\n");
  130.         //printf("%lld\n",res);
  131.     }
  132.     map<pair<int,int>,vector<int> >::iterator it=m2.begin();
  133.     printf("--------------------\n");
  134.     for(;it!=m2.end();++it)
  135.     {
  136.         if(is_prime(it->first.first))
  137.         {
  138.             printf("--------------------\n");
  139.             printf("(%d , %d ) : ",it->first.first,it->first.second);
  140.             vector<int>& w=it->second;
  141.             REP(ii,w.size())
  142.             {
  143.                 printf(" %d ",w[ii]);
  144.             }
  145.             printf("\n");
  146.         }
  147.     }
  148.     printf("--------------------\n");
  149. #ifdef HOME
  150.     fprintf(stderr,"time=%.3lfsec\n",0.001*(clock()-start));
  151. #endif
  152.     return 0;
  153. }
Advertisement
Add Comment
Please, Sign In to add comment