codefoces #404 C. Anton and Fairy Tale

来源:互联网 发布:mac重装失败 编辑:程序博客网 时间:2024/06/07 18:58

the reason of failiure:1、sqrt与sqrtl是不一样的,当精度较大的时候,应该使用sqrtl

2、函数ceil是求不大于a的第一个整数

用求根公式进行计算

#include <iostream>#include <stdio.h>#include<cmath>using namespace std;long long g1,g2,g3;int main(){    //freopen("in.txt","r",stdin);    int k,f1,f2,f3,n,f4,t1,t2,t3,t4,r,c;    cin >> g1 >> g2;    if(g2>g1){    cout << g1 <<endl;    return 0;    }    g1-=g2;    g3=ceil((-1+sqrtl(g1*8+1))/2);    cout << g3+g2 << endl;    return 0;}


0 0
原创粉丝点击