hdu_1005 Number Sequence
// 題目數據有問題 這樣都能過? 如果沒有循環就不行 但是數組也開不了那麽大 所以數據或者數據範圍有問題
#include<bits/stdc++.h> using namespace std; int main(){ int a[10000],x,y,n,m,i; a[1]=a[2]=1; while(scanf("%d%d%d",&x,&y,&n)){ if(x==0 && y==0 && n==0)break; for(i=3;i<10000;i++){ a[i]=(x*a[i-1]+y*a[i-2])%7; if(a[i-1]==1 && a[i]==1){ m=i-2; break; } } n=n%m; a[0]=a[i-2]; printf("%d\n",a[n]); } return 0; }
hdu_1005 Number Sequence
相關推薦
hdu_1005 Number Sequence
seq for () spa span ace 數據 std namespace // 題目數據有問題 這樣都能過? 如果沒有循環就不行 但是數組也開不了那麽大 所以數據或者數據範圍有問題#include<bits/stdc++.h> using names
Number Sequence HDU - 1711
contain while names http element mat line space smallest Given two sequences of numbers : a11 , a22 , ...... , aNN , and b11 , b22 , ....
HDU 1711 Number Sequence---KMP原始
情況 scanf n) 而不是 文件 -m scan stdlib.h cnblogs #include<stdio.h> #include<string.h> #include<math.h> #include<stdlib
[kmp]HDU1711 Number Sequence
模式 return print bsp clu cst pac -- () 題目大意 題意:給T組數據,每組有長度為n和m的母串和模式串。判斷模式串是否是母串的子串,如果是輸出最先匹配完成的位置,否則輸出-1. 思考 直接套用模板。把char改成int。kmp函
HDU 1005 Number Sequence
spa scanf scan %d content ble 取余 trac printf 題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=1005 找周期。當f(n)函數值再次出現1。1的時候就是一個循環
TOJ 1203: Number Sequence
contains http tom log .html clu image ons medium 1203: Number Sequence Time Limit(Common/Java):1000MS/10000MS Memory Limit:65536KBy
UVA 10689 Yet another Number Sequence 矩陣快速冪 水呀水
技術分享 ont truct string esp while .com tdi 快速冪 #include <iostream> #include <cstdio> #include <cstring> #include &
G - Number Sequence
test case cout kmp make play contains map return numbers Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ....
poj 1019 Number Sequence (數學)
http scan oid urn problem can set clu return 鏈接:http://poj.org/problem?id=1019 分析:就是計數的問題。。可以先算出112123...m共有多少位,具體式子看代碼。。然後二分取一個最大的小於n的m,
HDU - 1711 Number Sequence
esc -- nbsp scan mes each describe for ase Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 &
HDU 1711 Number Sequence【kmp】
show turn case put next() void 出現 回首 img Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1
【hdu1711】 Number Sequence
init 一段 mem for urn hdu include mes kmp 雖然noip很少有單獨把一些關於字符串的算法拉出來考,但是一定的練習也是必要的23333333333,至少要把板子打一遍吧2333333333333 這個題是一個裸到不能再裸的kmp,算是開始
HDU 4390 Number Sequence (容斥原理+組合計數)
osi freopen ret dsm algo .cn iterator push_back man HDU 4390 題意: 大概就是這樣。不翻譯了:
Number Sequence
warn pri war bre zeros for each OS contains algo Problem Description A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (
CodeForces - 393E Yet Another Number Sequence
space 二項式定理 ever title #define lse size void hat Discription Everyone knows what the Fibonacci sequence is. This sequence can be defined
HDU 1711 Number Sequence
div ace sync algorithm mes 足道 std int ipo 結題思路:KMP標準模板題,註意KMP有兩個版本,這裏的優劣在代碼中已體現 1 #include <iostream> 2 #include <cstring>
1005:Number Sequence(hdu,數學規律題)
his arch ear iostream tput ostream htm 數據 long Problem Description A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (
HDU 1711 Number Sequence (KMP簡單題)
bmi AMM several rip case ive sts -- 沒有 Number Sequence Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe
HDU 1711 -Number Sequence(KMP)
題目 Number Sequence Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s
hdoj 1711 Number Sequence KMP模板題
題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=1711 題目source:hdoj 1711 Number Sequence KMP分類難度級別1 題目含義:兩個數字串,尋找第二個數字串和第一個串中數字 匹配時候第一次出現的數字位置