时间显示(签到)
题解:
先除去“天数”影响。再从小到大算。
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr prinf
#define ll long long
int main() {
ll t;cin>>t;
t/=1000;//?
int a=t%(60*60*24);//多日影响去掉
t=a;
int c=t%60;//秒
t/=60;
int b=t%60;//分
t/=60;
a=t;
if(a/10==0)cout<<"0";
cout<<a<<":";
if(b/10==0)cout<<"0";
cout<<b<<":";
if(c/10==0)cout<<"0";
cout<<c<<endl;
return 0;
}
杨辉三角
题解:
找规律,然后二分答案。(明天补详细题解)
#include<iostream>
using namespace std;
#define ll long long
int n;
ll C(int a,int b){
ll res=1;
for(int i=a,j=1;j<=b;j++,i--){
res=res*i/j;
if(res>n)return res;
}
return res;
}
bool cheak(int k){
int l=k*2,r=max(n,l);
while(l<r){
int mid=l+r>>1;
if(C(mid,k)>=n){
r=mid;
}else{
l=mid+1;
}
}
if(C(r,k)==n){
cout<<1ll*(1+r)*r/2+k+1;
return true;
}
return false;
}
int main(){
cin>>n;
for(int i=16;i>=0;i--){
if(cheak(i))break;
}
return 0;
}