【2.10】

时间显示(签到)

题解:
先除去“天数”影响。再从小到大算。

#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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值