牛客小白月賽9 論如何出一道水題
鏈接:https://ac.nowcoder.com/acm/problem/19425
來源:牛客網
題目描述
給定 n,求一對整數 (i,j),在滿足 1 ≤ i ≤ j ≤ n 且 gcd(i,j)=1gcd(i,j)=1 的前提下,要求最大化 i+j 的值輸入描述:
第一行一個整數 n
輸出描述:
一行一個整數表示答案示例1
輸入
復制2
輸出
復制3
備註:
數據範圍18
1 ≤ n ≤ 10
#include<bits/stdc++.h> usingnamespace std; typedef long long LL;LL n; int main(){ while(cin>>n){ if(n==1)cout<<2<<endl; else cout<<n+n-1<<endl; } return 0; }
牛客小白月賽9 論如何出一道水題
相關推薦
牛客小白月賽9 論如何出一道水題
一行 ret mes include pre pro name its 題目 鏈接:https://ac.nowcoder.com/acm/problem/19425來源:牛客網 題目描述 給定 n,求一對整數 (i,j),在滿足 1 ≤ i
牛客小白月賽9 C 紅球進黑洞【線段樹+模擬位運算】
時間限制:C/C++ 3秒,其他語言6秒 空間限制:C/C++ 262144K,其他語言524288K 64bit IO Format: %lld 題目描述 在心理疏導室中有一種奇特的疏導工具,叫做紅球。紅球被提前分為了許多正方形小方格。 每當有人來找ATB做心理疏導時,AT
牛客小白月賽9 A 簽到【逆元】
時間限制:C/C++ 1秒,其他語言2秒 空間限制:C/C++ 262144K,其他語言524288K 64bit IO Format: %lld 題目描述 你在一棟樓房下面,樓房一共有n層,第i層每秒有pi的概率會扔下一個東西並砸到你 求第一秒內你被砸到的概率 輸入描述
牛客小白月賽9 A簽到(分數取模,逆元)
傳送門 對分母求一下逆元,把除法取模變成乘法取模,逆元介紹看這裡 這種方法只適合模為質數的情況 1 #include<bits/stdc++.h> 2 using namespace std; 3 const long long mod=1e9+7; 4
牛客小白月賽9 A B J
/** A 簽到 連結:https://ac.nowcoder.com/acm/contest/275/A ans:1-都沒有扔下來的概率; 處理逆元取模即可 */ #include<bits/stdc++.h> #define ll long long usi
【口胡系列】牛客小白月賽9
題目連結 挑了幾題口胡+寫了一發 這裡合在一起講好了 C: 經典題目 用 20 +
紅球進黑洞【線段樹區間更新+二進位制異或處理】【牛客小白月賽9-C】
題目連結 給你N個點,M次查詢,問的是(一)、區間【l, r】的數的總和;(二)、把區間【l, r】上的所有點去異或(xor)一個數X。 一開始用了點更新,然後T了,想了一會,最後在比賽結束前終於美滋滋的完成了AC,慶幸,我的想法是這樣的,將每個
牛客小白月賽9: D. 樹上求和(dfs序+線段樹)
連結:https://ac.nowcoder.com/acm/contest/275/D 來源:牛客網 題目描述 給你一棵根為1的有N個節點的樹,以及Q次操作。 每次操作諸如:1 x y:將節點x所在的子樹的所有節點的權值加上y2 x:詢問x所在子樹的所有節點的權值的平方和
牛客小白月賽9: F. 暴力出奇跡(思維題)
連結:https://ac.nowcoder.com/acm/contest/275/F 來源:牛客網 題目描述 給定一個序列,尋找一對l,r,滿足1 ≤ l ≤ r ≤ n 最大化的值 其中表示將al,al+1, ... , ar按位與後的結果 輸入描述: 第一行
牛客小白月賽9: div.2 A(線性篩)
連結:https://ac.nowcoder.com/acm/contest/275/J 來源:牛客網 題目描述 定義 f(n,k) 表示將 n 拆分成 k 個有序正整數乘積的方案數。 給定 n,k,,求f(1,k)~f(n,k) 舉個例子,假設要求 f(4,3) ,因為
2018牛客小白月賽9
文章目錄 C-紅球進黑洞 E-換個角度思考 離線求 主席樹求 C-紅球進黑洞 https://ac.nowcoder.com/acm/contest/275/C 題意: 兩種操作: 操作1:是求區間[L,R
牛客小白月賽9 A簽到
你在一棟樓房下面,樓房一共有n層,第i層每秒有p i的概率會扔下一個東西並砸到你 求第一秒內你被砸到的概率 輸入描述: 第一行一個整數n之後有n行,第i+1行有兩個整數a i ,b i ,表示 輸出描述: 設答案為 ,你只需要找到一個最
牛客小白月賽9-11.17
A.簽到(除數取模轉化為逆元快速冪) 連結:https://ac.nowcoder.com/acm/contest/275/A 來源:牛客網 你在一棟樓房下面,樓房一共有n層,第i層每秒有pi的概率會扔下一個東西並砸到你 求第一秒內你被砸到的概率 輸入描述: 第一行一個
牛客小白月賽9 A-簽到(逆元性質)
題目連結 https://ac.nowcoder.com/acm/contest/275/A 思路來源 https://ac.nowcoder.com/acm/contest/view-submission?submissionId=37485613 心得 get到了逆元的性質,
牛客小白月賽9 - A、B、C、H
A - 簽到 - 逆元 題目描述 你在一棟樓房下面,樓房一共有n層,第i層每秒有pi的概率會扔下一個東西並砸到你 求第一秒內你被砸到的概率 輸入描述: 第一行一個整數n 之後有n行,第i+1行有兩個整數ai,bi,表示 輸出描述: 設答案為,你只需要找到一個最小的非負整數T,
牛客小白月賽9
A題 費馬小 + 概率 每次輸入a b之後求反 算出這一層不扔的 概率 所有層不仍的概率相乘之後 再用1- 即得到被砸的概率 #include<bits/stdc++.h&g
牛客小白月賽9 J
/** J div.2 A 連結:https://ac.nowcoder.com/acm/contest/275/J 題意:f(n,k) n拆分為k個有序正整數乘積的方案數; ans = segmen
牛客小白月賽9 A簽到 數論————逆元
轉自:出處 複習內容:逆元的相關知識 在開始之前我們先介紹3個定理: 1.乘法逆元(在維基百科中也叫倒數,當然是 mod p後的,其實就是倒數不是嗎?): 如果ax≡1 (mod p),且gcd(a,p)=1(a與p互質),則稱a關於模p的乘法逆元為x。 2
牛客小白月賽9 A、B、C、D、E、H
傳送門 A 被砸到的概率 = 1 - 不被砸到的概率 而不被砸到的概率很容易計算。 程式碼: #include<cstdio> using namespace std; typedef long long ll; const ll mod=1e9+7; const
牛客網小白月賽9 論如何出一道水題(OJ題目ACM)
連結:https://ac.nowcoder.com/acm/contest/275/H 來源:牛客網 時間限制:C/C++ 1秒,其他語言2秒 空間限制:C/C++ 262144K,其他語言524288K 64bit IO Format: %lld 題目描述 給定 n,求一對整數