跳到正文

个人记录

rating 计算代码

Igallta约 2 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年8月6日
篇幅
约 2 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
#include<conio.h>
#define int long long
using namespace std;
int a = 600, b = 600;
const double e = 2.7182;
double f(double x) {
	return ceil(125.0 / (1.0 + 1.5 * pow(e, (x / 75.0))));
}
double g(double x){
	return ceil(25.0/(1.0+pow(e,(x/95.0))))+2;
}
mt19937_64 rnd(time(0));
int rndpo(int x){
	return rnd()%((int)g(x)); 
}
string change(int x){
	int tx=x;
	x=abs(x);
	string S="";
	while(x){
		S+=(x%10+'0');
		x/=10;
	}
	reverse(S.begin(),S.end());
	if(tx<0){
		S="(-)"+S;
	}
	else if(tx>0) S="(+)"+S;
	else S="(~)0";
	return S;
}
signed main() {
	cout<<"请输入初始 rating\n";
	cin>>a>>b;
	while (1) {
		int ta=a,tb=b;
		cout << "你们现在 rating 是:\n一号:" << a << "\n二号:" << b << '\n';
		cout << "谁赢得了这场比赛?(按a/b)。\n";
		char c = getch();
		c = toupper(c);
		if (c == 'A') {
			int zf = (int)f(a - b);
			a += (zf+rndpo(a));
			b =max(0LL,b-zf+rndpo(a-zf)/2);
		}
		if (c == 'B') {
			int zf = (int)f(b - a);
			a=max(0LL,a-zf+rndpo(a-zf)/2);
			b += (zf+rndpo(b));
		}
		system("cls");
		cout<<"涨幅:\n一号:"<<change(a-ta)<<"\n二号:"<<change(b-tb)<<'\n'; 
	}
	return 0;
}

Igallta:667

Emplace:538

原文