2013成都網路賽 兩個簡單題
We Love MOE Girls
Time Limit: 1000/500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 205 Accepted Submission(s): 154
Problem Description
Chikami Nanako is a girl living in many different parallel worlds. In this problem we talk about one of them.
In this world, Nanako has a special habit. When talking with others, she always ends each sentence with "nanodesu".
There are two situations:
If a sentence ends with "desu", she changes "desu" into "nanodesu", e.g. for "iloveyoudesu", she will say "iloveyounanodesu". Otherwise, she just add "nanodesu" to the end of the original sentence.
Given an original sentence, what will it sound like aften spoken by Nanako?
In this world, Nanako has a special habit. When talking with others, she always ends each sentence with "nanodesu".
There are two situations:
If a sentence ends with "desu", she changes "desu" into "nanodesu", e.g. for "iloveyoudesu", she will say "iloveyounanodesu". Otherwise, she just add "nanodesu" to the end of the original sentence.
Given an original sentence, what will it sound like aften spoken by Nanako?
Input
The first line has a number T (T <= 1000) , indicating the number of test cases.
For each test case, the only line contains a string s, which is the original sentence.
The length of sentence s will not exceed 100, and the sentence contains lowercase letters from a to z only.
For each test case, the only line contains a string s, which is the original sentence.
The length of sentence s will not exceed 100, and the sentence contains lowercase letters from a to z only.
Output
For every case, you should output "Case #t: " at first, without quotes. The t is the case number starting from 1. Then output which Nanako will say.
Sample Input
2
ohayougozaimasu
daijyoubudesu
Sample Output
Case #1: ohayougozaimasunanodesu
Case #2: daijyoubunanodesu
Source
題目地址:We Love MOE Girls
AC程式碼:
#include<iostream>
#include<cstring>
#include<string>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
char p[105];
char t[5];
int main()
{
int tes,i;
int cas=0;
int len;
scanf("%d",&tes);
while(tes--)
{
scanf("%s",p);
len=strlen(p);
printf("Case #%d: ",++cas);
if(len<4)
{
cout<<p<<"nanodesu"<<endl;
}
else
{
t[0]=p[len-4];
t[1]=p[len-3];
t[2]=p[len-2];
t[3]=p[len-1];
t[4]='\0';
if(strcmp(t,"desu")==0)
{
for(i=0;i<len-4;i++)
cout<<p[i];
cout<<"nanodesu"<<endl;
}
else
cout<<p<<"nanodesu"<<endl;
}
}
return 0;
}
A Bit Fun
Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 395 Accepted Submission(s): 254
Problem Description
There are n numbers in a array, as a0, a1 ... , an-1, and another number m. We define a function f(i, j) = ai|ai+1|ai+2| ... | aj . Where "|" is the bit-OR operation. (i <= j)
The problem is really simple: please count the number of different pairs of (i, j) where f(i, j) < m.
The problem is really simple: please count the number of different pairs of (i, j) where f(i, j) < m.
Input
The first line has a number T (T <= 50) , indicating the number of test cases.
For each test case, first line contains two numbers n and m.(1 <= n <= 100000, 1 <= m <= 230) Then n numbers come in the second line which is the array a, where 1 <= ai <= 230.
For each test case, first line contains two numbers n and m.(1 <= n <= 100000, 1 <= m <= 230) Then n numbers come in the second line which is the array a, where 1 <= ai <= 230.
Output
For every case, you should output "Case #t: " at first, without quotes. The t is the case number starting from 1.
Then follows the answer.
Then follows the answer.
Sample Input
2
3 6
1 3 5
2 4
5 4
Sample Output
Case #1: 4
Case #2: 0
Source
題目地址:A Bit Fun
AC程式碼:
#include<iostream>
#include<cstring>
#include<string>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int a[100005];
int main()
{
int tes,i,j;
int cas=0;
scanf("%d",&tes);
while(tes--)
{
int n,m;
int res=0;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
int tmp=0; //0|p=p
for(j=i;j<n;j++)
{
tmp=tmp|a[j];
if(tmp>=m)
break;
res++;
}
}
printf("Case #%d: %d\n",++cas,res);
}
return 0;
}
//171MS 620K
相關文章
- 藍橋杯省賽真題2013題解
- 簡單的分享兩個下載映象的網址
- 【leetcode 簡單】第二十題 合併兩個有序陣列LeetCode陣列
- bzoj3190: [JLOI2013]賽車(單調棧)
- 面試官:你能回答這兩個簡單的問題嗎面試
- 2018 徐州網路賽 G 題解
- 2024ccpc網路賽補題
- 成都鏈安榮登《嘶吼2022年網路安全產業圖譜》區塊鏈安全賽道榜單產業區塊鏈
- 【小白學PyTorch】1 搭建一個超簡單的網路PyTorch
- 【leetcode 簡單】 第八十五題 兩個陣列的交集 IILeetCode陣列
- 2013年省賽b組
- 用python手刃Leetcode(1):兩數之和【簡單題】PythonLeetCode
- 網路 IO 模型簡單介紹模型
- 18.合併兩個有序陣列(簡單)陣列
- Matlab2013a安裝簡單教程以及遇到的問題解決(反覆提示啟用問題)Matlab
- 簡單介紹網路(伺服器)線路伺服器
- 無線感測器網路簡明教程——單元習題/思考題/作業
- 簡單演算法題:leetcode-2 兩數相加演算法LeetCode
- 簡單演算法題:leetcode-1 兩數之和演算法LeetCode
- 簡單的神經網路測試神經網路
- 網路相關工具簡單彙總
- [ kvm ] 四種簡單的網路模型模型
- 簡單講講上下界網路流
- 最簡單的人工神經網路神經網路
- 一個簡單靜態網頁網頁
- 最佳化兩個簡單的巢狀迴圈巢狀
- 簡單練習Microsoft SQL Server MERGE同步兩個表ROSSQLServer
- 兩個簡單的擴充套件方法:TrimPrefix和TrimSuffix套件
- 華為走進成都 看智簡網路如何徹底改變企業?
- 一個簡單混合協議通訊列子,物聯網和網際網路通訊。協議
- 成都尚狐網路 ThinkPHP3.13核心PHP
- 【LeetCode刷題(簡單程度)】劍指 Offer 57. 和為s的兩個數字LeetCode
- 用Keras框架構建一個簡單的卷積神經網路!Keras框架架構卷積神經網路
- 網路安全網格概念以及特點簡單普及
- 【leetcode 簡單】 第八十七題 兩整數之和LeetCode
- [求職 go][成都] dp 的個人簡歷求職Go
- 利用BT構建簡單的CDN網路
- 網路通訊2:TCP簡單通訊TCP
- 簡單6步搞定Flutter網路請求Flutter