zoukankan      html  css  js  c++  java
  • POJ 1012 Joseph

    水题痛彻我心扉,就这样。 

    View Code
     1 #include<iostream>
     2 using namespace std;
     3 int main()
     4 {
     5     int a[14];
     6     int i,j,k,num = 2;
     7     while(num <= 13)
     8     {
     9         if(num == 0)
    10             break;
    11         for(i = 1;;i++)
    12         {
    13             j = 0;
    14             k = num * 2;
    15             while(1)
    16             {
    17                 j = (j + i) % k;
    18                 if(j == 0 || j > num)
    19                 {
    20                     k--;
    21                     if(k == num)
    22                     {
    23                         a[num] = i;
    24                         goto end;
    25                     }
    26                     if(j == 0)
    27                         j = k;
    28                     else
    29                         j--;
    30                 }
    31                 else
    32                     break;
    33             }
    34         }
    35 end:
    36         num++;
    37         continue;
    38     }//while
    39     int t;
    40     while(cin>>t)
    41     {
    42         if(t == 0)
    43             break;
    44         if(t == 1)
    45         {
    46             cout<<2<<endl;
    47             continue;
    48         }
    49         else
    50             cout<<a[t]<<endl;
    51     }
    52     return 0;
    53 }
  • 相关阅读:
    费马小定理
    CF 1365D Solve The Maze
    CF 1367D Task On The Board
    CF 1368B Codeforces Subsequences
    CF 1368C Even Picture
    mybatis框架
    Ajax
    jdbc
    jQuery
    JSP
  • 原文地址:https://www.cnblogs.com/zhexipinnong/p/2460725.html
Copyright © 2011-2022 走看看