zoukankan      html  css  js  c++  java
  • LightOJ---1008

    1.   
      Time Limit:500MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu 
      /********************************************** 
       
           author   :   *******
           time     :   *******
           algorithm:   数论 
           explain  :    对n开平方然后向上取整得到m: 
                            如果m为奇数: 
                                  if(m*m-n<m)    y=m;x=m*m-n+1; 
                                     else  x=m;y=n-(m-1)*(m-1); 
       
                            如果m为偶数: 
                                   if(m*m-n<m)    x=m;y=m*m-n+1; 
                                      else   y=m;x=n-(m-1)*(m-1); 
       
      **********************************************/  
      
      #include <iostream>
      #include <cstdio>
      #include <cstring>
      #include <algorithm>
      #include <cmath>
      #include <stack>
      #include <map>
      #include <vector>
      using namespace std;
      
      const int maxn=210;
      const int INF=0x3f3f3f3f;
      
      long long t,n,x,y;
      long long z;
      long long m;
      
      int main()
      {
          scanf("%d",&t);
          for(int i=1; i<=t; i++)
          {
              scanf("%lld",&n);
              z=sqrt(n*1.0);
      
              if(z*z==n) m=z;
              else m=z+1;
      
              if(m%2)
              {
                  if(m*m-n<m)
                  {
                      y=m;
                      x=m*m-n+1;
                  }
                  else
                  {
                      x=m;
                      y=n-(m-1)*(m-1);
                  }
              }
              else
              {
                  if(m*m-n<m)
                  {
                      x=m;
                      y=m*m-n+1;
                  }
                  else
                  {
                      y=m;
                      x=n-(m-1)*(m-1);
                  }
              }
              printf("Case %d: %lld %lld
      ",i,x,y);
          }
          return 0;
      }
  • 相关阅读:
    Servlet 规范 简介
    Redis简介
    some tips
    初识Servlet
    JVM基础知识
    使用typora编辑博客
    航海が始まる日
    比较好的IT教程网
    vue 使用心得---工作中一些关键点
    Vue父组件主动获取子组件的数据和方法
  • 原文地址:https://www.cnblogs.com/w-y-1/p/5755446.html
Copyright © 2011-2022 走看看