Discuz! Board

 找回密码
 立即注册
查看: 40|回复: 4

每日一题5.24

[复制链接]

5

主题

13

回帖

71

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
71

黄金骑士钻石大师

发表于 2025-5-23 20:50:20 | 显示全部楼层 |阅读模式
2024icpc昆明站--

H题铜牌入门级
银牌需要6题,C,L题
金牌7题有机会,E
C题:Coin - 题目 - QOJ.ac
wwj多交一个H题:Horizon Scanning - 题目 - QOJ.ac

屏幕截图 2025-05-23 205211.png

5

主题

13

回帖

71

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
71

黄金骑士钻石大师

 楼主| 发表于 2025-5-24 21:41:48 | 显示全部楼层
[C++] 纯文本查看 复制代码
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

void solve()
{
    LL n, k;
    cin >> n >> k;
    LL c = 0;
    if (k <= sqrtl(n)) {
        for (LL tmp = n; tmp; tmp -= (tmp + k - 1) / k) c++;
    }
    else {
        for (LL tmp = n; tmp; )
        {
            LL d = (tmp + k - 1) / k;
            LL rem = (tmp - 1) % k + 1;
            LL cnt = (rem + d - 1) / d;

            c += cnt;
            tmp -= d * cnt;
        }
    }
    c--;

    if (k <= sqrtl(n)) {
        LL x = 1;
        for (int i = 0; i < c; i++) x += (x + k - 1 - 1) / (k - 1);
        cout << x << '\n';
    }
    else {
        LL x = 1;
        for (LL i = 0; i < c; )
        {
            LL d = (x + k - 1 - 1) / (k - 1);
            LL rem = k - x % (k - 1);
            LL c1 = (rem + d - 1) / d;

            c1 = min(c1, c - i);
            x += c1 * d;
            i += c1;
        }
        cout << x << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
        

    return 0;
}
回复

使用道具 举报

8

主题

13

回帖

129

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
129

黄金骑士钻石大师

发表于 2025-5-24 21:56:56 | 显示全部楼层
[C++] 纯文本查看 复制代码
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int>PII;

void solve(){
	int n,k;
	cin>>n>>k;
	vector<double>ans;
	for(int i=1,x,y;i<=n;i++){
		cin>>x>>y;
		double t=atan2(y,x);
		if(y<0)t+=2*M_PI;
		ans.push_back(t);
	}
	sort(ans.begin(),ans.end());
	vector<double>temp=ans;
	for(auto i : temp){
		ans.push_back(i+2*M_PI);
	}
	double res=0;
	for(int i=k;i<ans.size();i++){
		res=max(res,fabs(ans[i]-ans[i-k]));
	}
	cout<<fixed<<setprecision(10)<<res<<endl;
}

signed main(){
	int t=1;ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>t;
	while(t--)solve();
	return 0;
}
回复

使用道具 举报

6

主题

15

回帖

80

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
80

黄金骑士

发表于 2025-5-24 22:32:43 | 显示全部楼层
#include<bits/stdc++.h>
using namespace std;

#define int long long

void solve(){
    int n,k;
    cin>>n>>k;
    int m=1;

    for(int T=0;T<2020;T++){
        int t=(m+k-2)/(k-1);
        int nxt=t*(k-1)+1;
        int num=(nxt-m+t-1)/t;
        if(m+t*num<=n){
            m+=t*num;
            continue;
        }
        int num1=(n-m)/t;
        m+=t*num1;
    }
    cout<<m<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin>>t;

    while(t--){
        solve();
    }

    return 0;
}
回复

使用道具 举报

8

主题

13

回帖

129

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
129

黄金骑士钻石大师

发表于 2025-5-25 03:18:49 | 显示全部楼层
[C++] 纯文本查看 复制代码
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int>PII;

void solve(){
	int n,k;
	cin>>n>>k;
	int cnt=0,lim=sqrt(n),t=n,pos=1;
	if(k<lim){//模拟
		while(t>1){
			t-=(t+k-1)/k;
			cnt++;
		}
		for(int i=1;i<=cnt;i++){
			pos=pos+(pos+k-2)/(k-1);
		}
	}else{
		while(t>1){
			int s=(t+k-1)/k,low=(s-1)*k+1;
			int tempcnt=(t-low)/s+1;
			if(s==1)tempcnt--;
			cnt+=tempcnt;
			t-=tempcnt*s;
		}
		while (cnt) {                     
			int a=(pos+k-2)/(k-1),next=a*(k-1)+1,d=(next-pos+a-1)/a;
			int step=min(d,cnt);            
			pos+=step*a;                      
			cnt-=step;
		}
	}
	cout<<pos<<endl;
}

signed main(){
	int t=1;ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>t;
	while(t--)solve();
	return 0;
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|DiscuzX ( 鄂ICP备2024088332号-1 )

GMT+8, 2025-6-7 11:08 , Processed in 0.099747 second(s), 34 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表