CF涼了是顯然的,不然也不會寫這篇反思了。
開題很快 了 和 。
到了 的時候定睛一看
Like any unknown mathematician, Yuri has favourite numbers: and , where . Yuri also likes triangles and once he thought: how many non-degenerate triangles with integer sides and exist, such that holds?
Yuri is preparing problems for a new contest now, so he is very busy. That’s why he asked you to calculate the number of triangles with described property.
The triangle is called non-degenerate if and only if its vertices are not collinear.
這段英文還是挺好懂的,就是說一個三角形三條邊分別爲 ,有如下限制
顯然等於
我們知道三角形要滿足 邊之和大於第 邊的。
所以
我的做法是枚舉 ,答案顯然 取值方案數 的取值方案數
對於 的取值方案數
我猛然想到《組合數學》上的內容,那是不久前剛學的所以現在十分記憶猶新,這種東西,我之前隻手算過,壓根兒也沒有想過有朝一日要用程序算出來。
回到題目
設
則
我們去化解
直接套無限多重集的多重集合的結論
設
我們來捋一捋
然後這個東西巨難調,好不容易過了 個樣例自信滿滿地去交得到的確實 聲一片。
這個題目的數據挺好造的,於是,我自信滿滿地打了個對拍,拍了幾組發現了幾個小問題逐一化解之後又交,又 。
時間就像嘩啦啦的小溪總是在不經意間悄無聲息地流走了。時間所剩無幾,但我也一直在努力。
之後突然發現這 個組合數可以直接求,於是有改了改代碼,還是 。
最後時刻,我把暴力一交發現暴力也 了,我絕望了。
此時的我排名已來到了 名,、 和 都沒有碰過,但也不敢碰了,不停的死磕 。
帶到倒計時種那蒼白而又孤獨的 的到來,無助的我也嘆了嘆氣。
窗外一片黑燈瞎火,只有房間還閃爍着些許亮光, 怒切 、、 和 ,更給孤獨的我的心頭埋上了一片陰霾。
風扇還在不停地轉動,我爲什麼就不能在繼續呢?
我開始了艱難而又漫長地調題,我在靜思中梳理,在思索中奮鬥,在 May/16/2020 22:52 我 了,我的心猶如初生的旭日般明亮, 的代碼和比賽最後一次提交的代碼僅僅有一處不同,而正是這一處讓我的分數悄然無息而又微妙地發生了變化。
回首再去看看對拍的代碼
代碼:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T>inline void read(T &FF) {
T RR = 1; FF = 0; char CH = getchar();
for (; !isdigit(CH); CH = getchar())if (CH == '-')RR = -1;
for (; isdigit(CH); CH = getchar())FF = (FF << 1) + (FF << 3) + (CH ^ 48);
FF *= RR;
}
template<typename T>inline void write(T FF) {
if (FF < 0) {
putchar('-');
FF *= -1;
}
if (FF > 9)write(FF / 10);
putchar(FF % 10 + 48);
}
template<typename T>inline void writen(T FF) {
write(FF);
puts("");
}
ll C(ll m, ll n) {
if (n == 0)return 1;
if (m <= 0 || n <= 0)return 0;
ll ans = 1;
for (ll i = 0; i < n; i++)ans *= m - i;
for (ll i = 1; i <= n; i++)ans /= i;
return ans;
}
ll work(ll i, ll l, ll r) {
return min(i - l + 1, r - l + 1);
}
ll xxx(ll a,ll b,ll c,ll d){
ll ans = 0;
for (ll i = c + 1; i <= b + c; i++) {
ll x = b - a, y = c - b;
ll m = i - a - b;
ll n = m + 1 - max((m - x), (ll)0) - max((m - y), (ll)0) + max((m - x - y), (ll)0);
ans += max(n, (ll)0) * max((ll)0, work(i - 1, c, d));
}
return ans;
}
ll xx(ll a,ll b,ll c,ll d){
ll ans=0;
for(int x=a;x<=b;x++){
for(int y=b;y<=c;y++){
ans+=max((ll)0,work(x+y-1,c,d));
}
}return ans;
}
int main() {
srand(time(NULL));
while(1){
ll a=1+rand()%20,b=a+rand()%20,c=b+rand()%20,d=c+rand()%20;
if(xx(a,b,c,d)!=xxx(a,b,c,d)){
cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
cout<<xx(a,b,c,d)<<" "<<xxx(a,b,c,d);
return 0;
}
}
return 0;
}
悲楚也會變得快樂。
的做法比我的做法簡單的多,但我的方法就是我的方法。
大佬說過:
自己選擇的路跪着也要走完
OI比賽似乎註定是無情的,在堅強的意志品質的同時,幾分理性同樣是不可或缺的,、 和 我明天再調qwq