• Codeforces Round #237 (Div. 2) B. Marathon(卡long long)


    题目:http://codeforces.com/contest/404/problem/B

     1 #include <iostream>
     2 #include <cstring>
     3 #include <cstdio>
     4 #include <cstdlib>
     5 #include <algorithm>
     6 using namespace std;
     7 
     8 int main()
     9 {
    10     __int64 g;   //g一定要是长整形,因为数据会超int.这个也是错误的最主要原因
    11     int n, i;
    12     double a, d, x, y, sum, cnt;
    13     while(~scanf("%lf%lf%d", &a, &d, &n))
    14     {
    15         sum = (double)(a*4);
    16         for(i = 1; i <= n; i++)
    17         {
    18             cnt = (double)i*d;
    19 
    20             g =(long long)(cnt/sum); //这里一定把要转换的部分加上括号
    21             cnt = (double)(cnt-g*sum);
    22             if(cnt-a<=0)
    23             {
    24                 y = 0;
    25                 x = cnt;
    26             }
    27             else if(cnt-2*a<=0)
    28             {
    29                 x = a;
    30                 y = cnt-a;  
    31             }
    32             else if(cnt-3*a<=0)
    33             {
    34                 x = a-(cnt-2*a);
    35                 y = a;
    36             }
    37             else
    38             {
    39                 x = 0;
    40                 y = a-(cnt-3*a);
    41             }
    42             printf("%.10lf %.10lf
    ", x, y);
    43         }
    44     }
    45     return 0;
    46 }
  • 相关阅读:
    13-计算属性和侦听器
    12-指令系统介绍
    11-vue的使用
    10-vue的介绍
    09-babel
    08-webpack的介绍
    07-nodejs中npm的使用
    06-Nodejs介绍
    05-面向对象
    Docker结合Jenkins构建持续集成环境
  • 原文地址:https://www.cnblogs.com/bfshm/p/3617062.html
Copyright © 2020-2023  润新知