NOIP 2012 提高組 複賽 day2 mod 同餘方程
#include <stdio.h>
void gcd(long long a,long long b,long long &d,long long &x, long long &y){
if(!b){
d=a;
x=1;
y=0;
}else{
gcd(b,a%b,d,y,x);
y-=a/b*x;
}
}
int main(){
long long a,b,d,x,y,b2;
long long t1,t2,t3,t4,t5;
scanf("%lld%lld%lld%lld%lld",&t1,&t2,&t3,&t4,&t5);
a=t3-t4;
b=t5*-1;
gcd(a,b,d,x,y);
if((t2-t1)%d!=0){
printf("Impossible\n");
}else{
b2=b/d;
x=((t2-t1)/d*x%b2+b2)%b2;
printf("%lld\n",x);
}
return 0;
}
相關推薦
NOIP 2012 提高組 複賽 day2 mod 同餘方程
//poj1061 青蛙的約會 #include <stdio.h> void gcd(long long a,long long b,long long &d,long long &x, long long &y){ if(!b){ d=a;
擴展歐幾裏得模板(洛谷1082 同余方程NOIP 2012 提高組 第二天 第一題)
its gcd pre 題目 兩個 描述 article 模板 strong 題目描述 求關於 x 的同余方程 ax ≡ 1 (mod b)的最小正整數解。 輸入輸出格式 輸入格式: 輸入只有一行,包含兩個正整數 a, b,用一個空格隔開。
[noip]2014年提高組複賽day2 解方程
#include <iostream> #include <cstdio> using namespace std; const long long u1=1000000007;//設為常量,不然70 long long n,m,a[5000],x,a
NOIP 2012 提高組 DAY1 T2 國王遊戲
space 一個空格 交換 得出 國慶 class getch sizeof ron 題目描述 恰逢 H 國國慶,國王邀請 n 位大臣來玩一個有獎遊戲。首先,他讓每個大臣在左、右 手上面分別寫下一個整數,國王自己也在左、右手上各寫一個整數。然後,讓這 n 位大臣排 成
NOIP 2012 提高組第二試模擬賽 Solution
div scanf efi display aps int alt empty sizeof 第一題 題意 數據範圍 Solution 三分求下凹函數最值 1 #include <cstdio> 2 #include <queue&
CCF-NOIP-2018 提高組(複賽) 模擬試題(四)
T1 貪吃蛇 【問題描述】 貪吃蛇是一個好玩的遊戲。在本題中,你需要對這個遊戲進行模擬。 這個遊戲在一個 \(n\) 行 \(m\) 列的二維棋盤上進行。 我們用 \((x, y)\) 來表示第 \(x\) 行第 \(y\) 列的格子,那麼左上角為 \((1, 1)\),右下角為 \((n, m)\)。
CCF-NOIP-2018 提高組(複賽) 模擬試題(七)
T1 Adjoin 【問題描述】 定義一種合法的\(0-1\)串:串中任何一個數字都與\(1\)相鄰。例如長度為$ 3 的 0-1 $串中,\(101\)是非法的,因為兩邊的\(1\)沒有相鄰的\(1,011\)是合法的,因為三個數都有\(1\)相鄰。現在問,長度為\(N\)的\(0-1\)中有多少是合法
NOIP-2018 提高組(複賽) 模擬試題之--T3思考熊的馬拉松
2018 NOIP 資料下載 題面描述 今年,只思考熊參加了校園馬拉松比賽。馬拉松的賽道是環形的,每圈的 長度是:,完成比賽需要跑;圈。 比賽中,甲領先乙很長距離,繞過一圈或多圈後從後面追上了乙的現象叫做 “套圈” 。 套圈現象非常常見, 例如: 跑得比誰都快的熊可以套某些熊 圈; 熊經常進
NOIP-2018 提高組(複賽) 模擬試題之--T2 最大佇列
2018 noip 資料大全 問題描述 給定一個長度為的排列(共包含個整數,每個數取值範圍和之間,且每個正整數出現並只出現一次)。藉助一個棧,依次將這個排列的每個元素進棧,並在合適的時候出棧,可以得到不同的出棧序列。不同的操作會帶來不同的出棧序列,請你求出在所有可能的方案中,字典序最大的
NOIP-2018 提高組(複賽) 模擬試題之--T1 帽子戲法
NOIP 2018資料下載 T1 帽子戲法 問題描述 小 Y 有一個n∗n∗nn∗n∗n的“帽子立方體” ,即一個nn層的立方體,每層的帽子都 可以排成n∗nn∗n的矩陣。 “帽子立方體”中的每一個帽子都有一個顏色,顏色共 26 種,用 26 個大寫字母來表示。 現在,小 Y 邀
CCF-NOIP-2018 提高組(複賽) 模擬試題(一)
T1 帽子戲法 問題描述 小 Y 有一個\(n*n*n\)的“帽子立方體” ,即一個\(n\)層的立方體,每層的帽子都 可以排成\(n*n\)的矩陣。 “帽子立方體”中的每一個帽子都有一個顏色,顏色共 26 種,用 26 個大寫字母來表示。 現在,小 Y 邀請小 F 來表演她的帽子戲法。小 F 會 \(2\)
CCF-NOIP-2018 提高組(複賽) 模擬試題(三)
T1 取球遊戲 問題描述 現有\(N\)個小球,依次編號為\(1\)到\(N\),這些小球除了編號以外沒有任何區別。從這\(N\)個小球中取出\(M\)個,請問有多少種取球方案使得在取出的\(M\)個小球中,編號最小的小球的編號為\(K\)。 考慮到方案數可能很大,請輸出方案數對\(1e9+7\)去模的值。
CCF-NOIP-2018 提高組(複賽) 模擬試題(五)
T1 相遇 【問題描述】 在一場奇怪的夢裡,小 Y 來到了一個神奇的國度。這個國度可以用一根數軸表示,小 Y 在 N 處,而小 Y 想吃的美食在 K 處。小 Y 有兩種方式移動, 一種叫做步行, 一種叫做瞬移。 對於每次步行操作,小 Y 可以從$ x $移動到 \(x + 1\) 或者 \(x – 1\),
CCF-NOIP-2018 提高組(複賽) 模擬試題(九)(2018 CSYZ長沙一中)
T1 Circle 【問題描述】 小 w 的男朋友送給小 w 一個 n 個點 m 條邊的圖,並且刁難小 w 要她找出點數最少的正環。 小 w 不會做,於是向你求助。 【輸入格式】 第一行兩個整數\(n,m\) 接下來\(m\)行,每行四個數\(u,v,a,b\),表示從\(u\)走到\(v\)的代價為\(a\
NOIP 2015 提高組複賽試題
CCF 全國資訊學奧林匹克聯賽(NOIP2015)複賽 提高組 day1 (請選手務必仔細閱讀本頁內容) 一.題目概況 中文題目名稱 神奇的幻方 資訊傳遞 鬥地主 英文題目與子目錄名 magic message landlords
NOIP 2012 提高組 借教室
在大學期間,經常需要租借教室。大到院系舉辦活動,小到學習小組自習討論,都需要向學校申請借教室。教室的大小功能不同,借教室人的身份不同,借教室的手續也不一樣。 面對海量租借教室的資訊,我們自然希望程式設計解決這個問題。我們需要處理接下來n天的借教室資訊,其中第i天學校有ri個教室可供租借。共有m份訂單,每份訂
NOIP 2012 提高組 Vigenère密碼
16世紀法國外交家Blaise de Vigenère設計了一種多表密碼加密演算法——Vigenère密碼。Vigenère密碼的加密解密演算法簡單易用,且破譯難度比較高,曾在美國南北戰爭中為南軍所廣泛使用。 在密碼學中,我們稱需要加密的資訊為明文,用M表示;稱加密後的資訊為密文,用C表示;而金鑰是一種引
p1434 [noip2012]day2-T1同餘方程
題目 https://www.luogu.org/problemnew/show/P1082 程式碼 #include<bits/stdc++.h> using namespace std; typedef long long ll; ll a, b, x, y;
Noip2012 Day2 T1 同餘方程(擴充套件歐幾里得)
題目描述 求關於 x 的同餘方程 ax ≡ 1 (mod b)的最小正整數解。 輸入輸出格式 輸入格式: 輸入只有一行,包含兩個正整數 a, b,用一個空格隔開。 輸出格式: 輸出只有一行,包含一個正整數 x0,即最小正整數解。輸入資料保
【NOIP】提高組2012 疫情控制
closed ide span sin 容易 lld isdigit i++ 表示 【題意】n個點的樹,1為根,要求刪除一些點使得截斷根節點和所有葉子結點的路徑(不能刪根,可以刪葉子)。有m支軍隊在m個點上,每時刻所有軍隊可以走一步,最終走到的地方就是刪除的點,求最短時間。