这题纯脑残了 分奇偶处理一下就行了
链接 :https://atcoder.jp/contests/arc102/tasks/arc102_a
#include<bits/stdc++.h> #define rep(i,a,n) for(int i=a;i<=n;++i) #define per(i,a,n) for(int i=n;i>=a;--i) #define pb push_back #define fi first #define se second #define io std::ios::sync_with_stdio(false) using namespace std; typedef long long ll; typedef pair<int,int> pii; const int P = 1e9+7, INF = 0x3f3f3f3f; const int maxn=1e5+50; ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; } ll qpow(ll a,ll n) { ll r=1%P; for (a%=P; n; a=a*a%P,n>>=1)if(n&1)r=r*a%P; return r; } int main() { int n,k; cin>>n>>k; ll ans=n/k; ans=ans*ans*ans; if(k%2==0) { n-=k/2; if(n>=0) { ll x=n/k+1; ans+=x*x*x; } } cout<<ans<<endl; }