← 回到文章列表

Zoj2965________纠结的Wrong Answer

今天一直在弄Zoj的2965 但是奇怪的是自己在Cfree上编译通过 但是上传到服务器测试就Wrong Answer 汗流浃背的在四处问 他们都说没错阿= =ll   VC++也编译通过 后来在Ubuntu里面运行了下果然报错了..... 好吧  windows的编译器就是这么的…

今天一直在弄Zoj的2965
但是奇怪的是自己在Cfree上编译通过
但是上传到服务器测试就Wrong Answer
汗流浃背的在四处问
他们都说没错阿= =ll   VC++也编译通过
后来在Ubuntu里面运行了下果然报错了…..
好吧  windows的编译器就是这么的不可靠
原因出现在变量"i"没有初始化……
OMG阿OMG   我的一个小时….~~~~~
nextpage\

Accurately Say “CocaCola”!
Time Limit: 1 Second      Memory Limit: 32768 KB

——————————————————————————–

In a party held by CocaCola company, several students stand in a circle and play a game.

One of them is selected as the first, and should say the number 1. Then they continue to count number from 1 one by one (clockwise). The game is interesting in that, once someone counts a number which is a multiple of 7 (e.g. 7, 14, 28, …) or contains the digit ‘7’ (e.g. 7, 17, 27, …), he shall say “CocaCola” instead of the number itself.

For example, 4 students play this game. At some time, the first one says 25, then the second should say 26. The third should say “CocaCola” because 27 contains the digit ‘7’. The fourth one should say “CocaCola” too, because 28 is a multiple of 7. Then the first one says 29, and the game goes on. When someone makes a mistake, the game ends.

During a game, you may hear a consecutive of p “CocaCola"s. So what is the minimum number that can make this situation happen?

For example p = 2, that means there are a consecutive of 2 “CocaCola"s. This situation happens in 27-28 as stated above. 27 is then the minimum number to make this situation happen.

Input

Standard input will contain multiple test cases. The first line of the input is a single integer T (1 <= T <= 100) which is the number of test cases. And it will be followed by T consecutive test cases.

There is only one line for each case. The line contains only one integer p (1 <= p <= 99).

Output

Results should be directed to standard output. The output of each test case should be a single integer in one line, which is the minimum possible number for the first of the p “CocaCola"s stands for.

Sample Input


2
2
3


Sample Output


27
70


nextpage
代码如下:
\

#include"stdio.h"
#include"string.h"
#define max 800                                   
long seven(long x)
{
  long i,j=1,a[max],z=1,count=0;
  for(i=1;i<max;i++)                               //提取符合規則的數存入a數組中 
  if(i%7==0||i/100==7||i/10%10==7||i%10==7)
    {
       count++;                                    // conut主要用來控制循環 
     a[j]=i; 
       j++; 
    }    
    if(x==1)                                       //黨輸入為1時   
     {  printf("7\n");                           //直接輸出數值"7"
          return 0; 
     }                               
      for(j=2;j<=count;j++)                          //Z用來儲存連續字符個數 初始值為1                      
       {
         
       if(a[j]-a[j-1]==1)                          //黨數組連續兩個數相差1                              
      z++;                                       //z數值+1                                 
         else                                        //否則z初始化為1     
           z=1;  
     if(z==x)                                    //黨z等於輸入的數字時候                             
     { 
          printf("%d\n",a[j-x+1]);                   //輸出連續數字的第一位數   
         return 0;                                   //結束循環 
     }                                 
       }
}
int main()
{
    long t,r,u;
  scanf("%d",&t);
  if(t<1||t>100)
  return 0;
  for(r=0;r<t;r++)
  {
  scanf("%d",&u);
  seven(u);
  }
}




注意  你们可以尝试一下吧开头的long后面的"i=1"的”=1"部分去掉
在CFREE或者VC++下编译
傻眼了吧??????
不仅正常运行
并且答案完全正确  = =
nextpage
[媒体不可用]
[媒体不可用]
\

写下来,是为了下次少走一点弯路。

在这里找找

输入关键词,找一篇过去的记录。