3 条题解
-
212116黄立博 (12116黄立博) LV 9 @ 2022-07-10 16:46:09
#include<iostream> using namespace std; long long n,s=0,n1,i; int main() { cin>>n>>n1; i=n; while(i<=n1) { if(i+40000000000000<=n1) i+=40000000000000,s+=9700000000000; else if(i+40000000000<=n1) i+=40000000000,s+=9700000000; else if(i+4000000<=n1) i+=4000000,s+=970000; else for(i;i<=n1;i++) if(i%400==0||i%4==0&&i%100!=0) s++; } cout<<s; return 0; } //可以化简一下
-
22022-02-01 12:34:17@
绝对不超时
#include<iostream> #include<iomanip> #include<cmath> using namespace std; int main() { long long a,b,i,s=0; cin>>a>>b; i=a; for(;i<=b;) { if((i%4==0&&i%100!=0)||(i%400==0&&i+400>b)) { s++; } while(i+40000000000000<=b) { i+=40000000000000; s+=9700000000000; } while(i+40000000000<=b) { i+=40000000000; s+=9700000000; if(i%40000000000000==0&&i+40000000000000<=b) break; } while(i%40000000==0&&i+40000000<=b) { i+=40000000; s+=9700000; if(i%40000000000==0&&i+40000000000<=b) break; } while(i%400000==0&&i+400000<=b) { i+=400000; s+=97000; if(i%40000000==0&&i+40000000<=b) break; } while(i%400==0&&i+400<=b) { i+=400; s+=97; if(i%400000==0&&i+400000<=b) break; } i++; } if(a%400==0||a%4==0&&a%100!=0) s++; if(b%400==0||b%4==0&&b%100!=0) s++; cout<<s; //fixed<<setprecision() return 0; }
不超时的代码
-
-52021-12-30 16:12:27@
#include<iostream>
using namespace std;
int main()
{
long long a,b,m=0;
cin>>a>>b;
for(long long i=a;i<=b;i++)
{
if(i==0)
m+=0;
else
{
if((i%100==0&&i%400==0)||(i%100!=0&&i%4==0))
m++;
}}
cout<<m;
return 0;
}
- 1
信息
- ID
- 1625
- 难度
- 7
- 分类
- (无)
- 标签
- 递交数
- 308
- 已通过
- 54
- 通过率
- 18%
- 上传者