計蒜客-Chessboard Dancing(思維題)
不要怕長題! 不要怕長題! 不要怕長題!
90%的長題都很簡單。
這道題其實仔細想一下拿個紙畫一下就可以了,感覺更多的是在考翻譯。
#include<iostream> #include<cstdio> #include<algorithm> #include<math.h> using namespace std; int main() { int S; char ty[5]; while(scanf("%d%s",&S,ty) != EOF){ if(*ty == 'R' || *ty == 'B') printf("%d\n",S); else if(*ty == 'K') printf("%d\n",min(4,S*S)); else printf("%d\n",(S<=2 ? 1 : 2)); } return 0; }
相關推薦
計蒜客-Chessboard Dancing(思維題)
不要怕長題! 不要怕長題! 不要怕長題! 90%的長題都很簡單。 這道題其實仔細想一下拿個紙畫一下就可以了,感覺更多的是在考翻譯。 #include<iostream> #include<cstdio> #include<algorithm
計蒜客載入數字(密題)
小蒜把1-n這n個數字寫進記憶體,但是除了用二進位制格式寫的數字(只包含0,1的數字)都失敗了,現在他想知道有多少個數字載入成功了。 輸入格式 一個整數 n(1≤n≤10^9) 輸出格式 一個整數表示載入成功的數字個數 樣例輸入 10 樣例輸出 2 這道題思路
計蒜客--爬樓梯 (動態規劃)
tle nbsp vector main long 3.1 false n) 方法 假設你現在正在爬樓梯,樓梯有 nn 級。每次你只能爬 11 級或者 22 級,那麽你有多少種方法爬到樓梯的頂部? 輸入格式 第一行輸入一個整數 n(1\leq n \leq 50)n
計蒜客:灌溉(生成樹)
https://nanti.jisuanke.com/t/34 到了旱季農業生產的灌溉就成了一個大問題。為了保證灌溉的順利,某縣政府決定投資為各個村之間建立灌溉管道。 輸入第1行包括一個整數N,表示某縣的村莊的數量。(3≤N≤100),第2行-結尾為一個N×N的矩陣,表示每個村莊之間的距
計蒜客 矩陣變換 (bfs+set)
題目: 題目大意: 讓你求解出原字串怎樣通過已有的規則變化為目標串,輸出所用到的規則。 題目思路: 這樣的話,我們先將所謂的規則寫成相應的函式,然後利用bfs進行字串的變換,知道字串變為目標串結束,如果你不進行visit標記的話,那麼MLE,如果採用O(n)的方法來標記的
計蒜客16495 Truefriend(fwt)
ios public () eof .cn png pac log typedef #include <iostream> #include <cstring> #include <cstdio> using namespace st
計蒜客16492 building(二分線段樹/分塊)
sin cst include sqrt ++ building scanf mat math 題解: 考慮用線段樹維護樓的最大值,然後這個問題就很簡單了。 每次可以向左二分出比x高的第一個樓a,同理也可以向右二分出另一個樓b,如果a,b都存在,答案就是b-a-1。 註意到
牛客小白月賽9: F. 暴力出奇跡(思維題)
連結:https://ac.nowcoder.com/acm/contest/275/F 來源:牛客網 題目描述 給定一個序列,尋找一對l,r,滿足1 ≤ l ≤ r ≤ n 最大化的值 其中表示將al,al+1, ... , ar按位與後的結果 輸入描述: 第一行
計蒜客 Mathematical Curse(ACM-ICPC 2018 焦作賽區網路預賽 B)(DP)
A prince of the Science Continent was imprisoned in a castle because of his contempt for mathematics when he was young, and was entangled
計蒜客 Transport Ship(ACM-ICPC 2018 焦作賽區網路預賽 K)(多重揹包裝滿的方案數)
There are NN different kinds of transport ships on the port. The i^{th}ith kind of ship can carry the weight of V[i]V[i] and the number of
計蒜客上藍橋杯模擬題的部分題解
<A> 思路:按照題意暴力就行了,答案是1. AC程式碼: #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxx = 1e5
計蒜客 Transport Ship (2018-ACM-ICPC-焦作-網路賽)DP
There are NN different kinds of transport ships on the port. The i^{th}ith kind of ship can carry the weight of V[i]V[i] and the number of
計蒜客 挑戰難題 第14題:羅馬數字轉換成整數
給定一個羅馬數字s,( I<=s<=MMMCMXCIX)(即1到3999),將羅馬數字轉換成整數。 如羅馬數字I,II,III,IV,V分別代表數字1, 2, 3, 4, 5。 格式: 第一行輸入一個羅馬數字,接下來輸出對應的整數。 提示: 首先要來了解一下羅馬數字表示法,基本字元
計蒜客 抄襲檢測 (最長公共子串)
#include<stdio.h> #include<algorithm> #include<cstring> #include<iostream> const int MAXN = 2e5+10; int r[MAX
計蒜客 挑戰難題 第9題:元素移除
給定一個數組和一個數(該數不一定在陣列中),從數組裡刪掉這個數字,返回剩下的陣列長度。 如:A[] = {1, 2, 3, 4, 5}, 要刪除數字3, 那麼返回陣列長度為4. 親愛的小夥伴們,題目是不是很簡單呢? 提示: int removeElement(int A[], int n, int e
計蒜客 挑戰難題 第10題:尋找插入位置
給定一個已經升序排好序的陣列,以及一個數target,如果target在陣列中,返回它在陣列中的位置。 否則,返回target插入陣列後它應該在的位置。 假設陣列中沒有重複的數。以下是簡單的示例: [1,3,5,6], 5 → 2 [1,3,5,6], 2 → 1 [1,3,5,6], 7 → 4 [1
計蒜客 挑戰難題 第20題:跳躍遊戲二
時間限制 1000 ms 記憶體限制 10000 K 給定一個非負整數陣列,假定你的初始位置為陣列第一個下標。 陣列中的每個元素代表你在那個位置能夠跳躍的最大長度。 你的目標是到達最後一個下標,並且使用最少的跳躍次數。 例如: A = [2,3,1,1,4], 到達最後一個下標的最少跳躍次
計蒜客 挑戰難題 第11題:移除陣列中的重複元素
時間限制 1000 ms 記憶體限制 10000 K 給定一個升序排列的陣列,去掉重複的數,並返回新的陣列的長度。 例如: 陣列A = {1, 1, 2},你的函式應該返回長度2,新陣列為{1, 2} 要求: 不能新開陣列分配額外的空間。即常數空間限制。 提示: 輸入一個整數n,以
計蒜客--農場看守(簡單的歐拉回路)
蒜頭君最近做了農場看守,他每天晚上的工作就是巡視農場並且保證沒有人破壞農場。從穀倉出發去巡視,並且最終回到穀倉。 蒜頭君視力不太好,其他農場守衛只需要對農場的每一條連線不同場地的路走一遍就可以發現是不是有異常情況了。但是他很仔細和耐心,對農場的每一條連線不同場地的路需要走
計蒜客 挑戰難題 第12題:最後一個單詞的長度
嘗試次數 3099次 通過率 7.19% 時間限制 1000 ms 記憶體限制 10000 K 給定由大寫,小寫字母和空格組成的字串,返回最後一個單詞的長度。 如果不存在最後一個單詞,返回0 注意: “單詞”是指不包含空格符號的字串 例如: s = “hello World”