zoukankan      html  css  js  c++  java
  • uva 10161

     1 #include<stdio.h>
     2 
     3 int main()
     4 {
     5     int s ;
     6      while(scanf("%d",&s)==1 && s)
     7      {
     8          int x = 1;
     9          int m = 1 , n = 1 ;
    10          while (1)
    11              if(x*x <= s && s < (x+1)*(x+1) ) break;
    12             else  x++;
    13 
    14             if( s == x*x)
    15                 if(x%2 == 0) {printf("%d 1
    ",x) ;continue;}
    16                 else {printf("1 %d
    ",x) ; continue;}
    17             int va = x*x;
    18             if(x % 2 == 0)
    19             {
    20                 int i = 0 ;
    21                 m = x  ;n = 1;
    22                 m++;va++;
    23                 while( s > va && i< x)
    24             {
    25                 n++;
    26                 va++;
    27                 i++;
    28             }
    29             i = 0 ;
    30             while(s > va && i < x )
    31             {
    32                 m--;
    33                 va++;
    34                 i++;
    35             }
    36             printf("%d %d
    ",m,n);
    37             }
    38             else
    39             {
    40               int i = 0 ;
    41                 n = x  ;m = 1;
    42                 n++;va++;
    43                 while( s > va && i< x)
    44             {
    45                 m++;
    46                 va++;
    47                 i++;
    48             }
    49             i = 0 ;
    50             while(s > va && i < x )
    51             {
    52                 n--;
    53                 va++;
    54                 i++;
    55             }
    56             printf("%d %d
    ",m,n);
    57             }
    58      }
    59     return 0 ;
    60 }

    前几次WA  后来把s!=va  改为 s>va  才过 

    不知道  为什么  以后还是注意点!

  • 相关阅读:
    iSCSI又称为IPSAN
    文档类型定义DTD
    HDU 2971 Tower
    HDU 1588 Gauss Fibonacci
    URAL 1005 Stone Pile
    URAL 1003 Parity
    URAL 1002 Phone Numbers
    URAL 1007 Code Words
    HDU 3306 Another kind of Fibonacci
    FZU 1683 纪念SlingShot
  • 原文地址:https://www.cnblogs.com/shaughn/p/3421740.html
Copyright © 2011-2022 走看看