菜的真實,普及都 ak 不掉..
score: 100 + 100 + 100 + 0 = 300
rank: 16
看來 pj t1 考字串讀入成鐵上釘釘了?
考慮開桶 \(a\) ,記錄 ascii 為 \(i\) 的字元是否出現即可。
#includeusing namespace std;
typedef long long ll;
const int maxn = 100000 + 7;
const int maxm = 200000 + 7;
int n, m;
#ifdef graph_define
int head[maxn], to[maxm], next[maxm], tot;
void addedge(int x, int y)
void add(int x, int y)
#endif
template < typename tp >
void read(tp &x)
string s;
bool a[200];
void init(void)
int ans;
void work(void)
cout << ans << '\n';
}int main()
發現 \(a_i \le 10^9\) ,考慮到 \(2^ >> 10^9\) ,所以對這些數暴力分解,列舉到其 \(22\) 次方的和即可。
#includeusing namespace std;
#define int long long
typedef long long ll;
const int maxn = 100000 + 7;
const int maxm = 200000 + 7;
int n, m;
#ifdef graph_define
int head[maxn], to[maxm], next[maxm], tot;
void addedge(int x, int y)
void add(int x, int y)
#endif
template < typename tp >
void read(tp &x)
int t;
void init(void)
int ans;
int fpow(int x, int p)
return res;
}bool check(int x)
int k = (int)v.size();
int times = 0;
while(copy < x && times <= 22)
if(copy == x) return true;
if(copy > x) return false;
++times;
} return false;
}void work(void)
printf("%lld\n", ans);
}signed main()
換根樹形 dp。
先欽定 \(1\) 為根,把 dep 都跑出來。
假設當前 \(x\) 為根,向 \(y\) 換根時,有 \(n - size_y\) 的點距離增加一,有 \(size_y\) 個點距離減少一。
所以搜一遍就出來了。
另外,看到有人寫了乙個樹的重心 a 掉了,不是很理解。
#includeusing namespace std;
typedef long long ll;
const int maxn = 1000000 + 7;
const int maxm = 2000000 + 7;
const int inf = 0x3f3f3f3f;
int n, m;
#define graph_define
#ifdef graph_define
int head[maxn], to[maxm], next[maxm], tot;
void addedge(int x, int y)
void add(int x, int y)
#endif
template < typename tp >
void read(tp &x)
void init(void)
}int dep[maxn], size[maxn], sum[maxn];
void dfs1(int x, int f, int dp)
}int ans = inf;
void dfs2(int x, int f, int val)
}void work(void)
int main()
不會,好神仙的題啊,在此膜拜切掉的那群神仙。
官方題解:
所以為啥不把資料範圍開大點出個矩陣快速冪啊...
牛客OI周賽14 普及組全部題解
eg 好久不見的普及組題目,自信滿滿以為自己ak了,結果c題莫名被卡常 後來開了氧氣優化就過了,我一直以為氧氣優化評測機會自己開不用手動開 d題公式精度問題被卡,最後rk14,btw牛客一場上綠還是很高興的嘿嘿嘿。傳送門題意 統計乙個字串裡有多少個不同的字元。題解 map或者set隨便搞。inclu...
牛客OI周賽9 普及組
目錄a題 b題 c題 小q挺喜歡擼串的,沒錯,字串!你給小q送上了n個字串 對於乙個字串s,如果在小q擼掉 刪除 任意個字元之後,nowcoder 是其子串,則這個字串s是可擼的。小q最近切題切到手軟,想擼串散散心。如果你給他呈現的字串是可擼的,他會很開心,否則他會很桑心。輸入描述 乙個整數n,表示...
牛客OI周賽7 普及組
比賽鏈結 這題非常簡單,純模擬就可以過,不用解釋 如下 includeusing namespace std struct gg a 10005 int main cin m for int i 1 i m i cout 這題目看起來仍然簡單。但最開始我還以為要把所有區間全部列舉一遍。然後我打出暴力...