python 牛客 飢餓的小易
數學題 1.fg=gf 2.fff=gg
start=int(input())
count1=0
count2=1
count3=2
m=1000000007
start1=start%m
start2=(4*start1+3)%m
start3=(4*start2+3)%m
while count1<100000 and start1!=0:
start1=(8*start1+7)%m
count1+=1
while count2<100000 and start2!=0:
start2=(8*start2+7)%m
count2+=1
while count3<100000 and start3!=0:
start3=(8*start3+7)%m
count3+=1
count=min(count1,count2,count3)
count=-1 if count==100000 else count
print(count)
相關推薦
python 牛客 飢餓的小易
數學題 1.fg=gf 2.fff=gg start=int(input()) count1=0 count2=1 count3=2 m=1000000007 start1=start%m start2=(4*start1+3)%m start3=(4*start2+3)%m while
牛客練習-小易喜歡的單詞
小易喜歡的單詞具有以下特性: 1.單詞每個字母都是大寫字母 2.單詞沒有連續相等的字母 3.單詞沒有形如“xyxy”(這裡的x,y指的都是字母,並且可以相同)這樣的子序列,子序列可能不連續。 例如: 小易不喜歡"ABBA",因為這裡有兩個連續的'B' 小易不喜歡"THETXH",因為這裡包含子序列"
python 牛客 小易喜歡的單詞
這裡可以用正則匹配這樣的騷方法 s=input() import re pattern1 = re.compile(r"[^A-Z]+") pattern2 = re.compile(r"([A-Z])\1") pattern3 = re.compile(r"([A-Z])[A-Z]*(
牛客網小白月賽1 B,I
hide print cout const map ostream splay typedef inf 1 #include <stdio.h> 2 #include <math.h> 3 #include <string.h>
2018年,牛客網小白月賽5
bject www urn 小時 %d describe desc bsp n+2 第一次啊,補題,希望大佬批評。 題目按我補題順序來的。 https://www.nowcoder.com/acm/contest/135#question H 題 最大公倍數 題意:給出兩
牛客網小a的旅行計劃
地址:https://ac.nowcoder.com/acm/contest/223/B 此題是一道套公式題目,不難,ans=(pow(4,n+1)-4*pow(3,n+1)+6*pow(2,n+1)-4)*pow(8,mod-2) #include <cstdio> #incl
牛客網小白月賽7送分題
連結:https://ac.nowcoder.com/acm/contest/190/A 時間限制:C/C++ 1秒,其他語言2秒 空間限制:C/C++ 32768K,其他語言65536K 64bit IO Format: %lld 題目描述 做水題就是在浪費時間,但是一場比賽要是沒有送
牛客網小白月賽9 論如何出一道水題(OJ題目ACM)
連結:https://ac.nowcoder.com/acm/contest/275/H 來源:牛客網 時間限制:C/C++ 1秒,其他語言2秒 空間限制:C/C++ 262144K,其他語言524288K 64bit IO Format: %lld 題目描述 給定 n,求一對整數
牛客網小白月賽7 BFS
連結:https://ac.nowcoder.com/acm/contest/190/F 來源:牛客網 時間限制:C/C++ 1秒,其他語言2秒 空間限制:C/C++ 32768K,其他語言65536K 64bit IO Format: %lld 題目描述 Bob在學習了DFS後,自
牛客網小白月賽6D 字串絲帶
時間限制:C/C++ 1秒,其他語言2秒 空間限制:C/C++ 65536K,其他語言131072K 64bit IO Format: %lld 題目描述 WHZ送給了HtBest一個“字串絲帶”,這
牛客網小白月賽8神祕鑰匙
時間限制:C/C++ 1秒,其他語言2秒 空間限制:C/C++ 32768K,其他語言65536K 64bit IO Format: %lld 題目描述 clccle一行?個人來到了一個詭異的世界,她
牛客網小白月賽7 BFS
時間限制:C/C++ 1秒,其他語言2秒 空間限制:C/C++ 32768K,其他語言65536K 64bit IO Format: %lld 題目描述 Bob在學習了DFS後,自己又發明了一種新的搜
牛客網——小白鼠排隊(桶排序)
題目描述 N只小白鼠(1 <= N <= 100),每隻鼠頭上戴著一頂有顏色的帽子。現在稱出每隻白鼠的重量,要求按照白鼠重量從大到小的順序輸出它們頭上帽子的顏色。帽子的顏色用“red”,“blue”等字串來表示。不同的小白鼠可以戴相同顏色的帽子。白鼠的重量用整數表示。 輸入描
python 牛客真題 合唱團
n=int(input()) performance=list(input().split()) kd=list(input().split()) k=int(kd[0]) d=int(kd[1]) dp=[[0]*n for _ in range(k)] dp1=[[0]*n for _
牛客網 - 小A的期末作業
題目連結:https://ac.nowcoder.com/acm/contest/322/I 時間限制:C/C++ 1秒,其他語言2秒 空間限制:C/C++ 32768K,其他語言65536K 64bit IO Format: %lld 題目描述 期末了, 老師給小A佈置了一
python 牛客 迴文序列
n=int(input()) num=list(map(int,input().split())) cnt=0 p=0 q=n-1 lft=num[0] rht=num[n-1] while p<q: if lft==rht: p+=1 q-=1
python 牛客 兩種排序方法
n=int(input()) list1=[] i=0 curl=1 f1=True while i<n: s1=input() if f1: if len(s1)<curl: f1=False curl=l
python 牛客真題 統計迴文
s=input() t=input() def judge(s): ls=len(s) for i in range(ls//2): if s[i] != s[ls-1-i]: return False return True
python 牛客真題 不要二
num=input().split() n=int(num[0]) m=int(num[1]) if m%4==2: m,n=n,m tmp1=(m+1)//2 tmp2=m-tmp1 mysum=0 for i in range(n): if i%4==0 or i%4==
python 牛客真題 幸運的袋子
DFS,需要剪枝 n=int(input()) num=list(map(int,input().split())) num.sort() def dfs(num,mysum,mymul): count=0 for i in range(len(num)):