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成都網路賽1004題HDU 4731Minimum palindrome (思維題目)
- 2013杭州網路賽C題HDU 4640(模擬)
- 2013長沙網路賽H題Hypersphere (蛋疼的題目 神似邀請賽A題)
- 關於兩個簡單問題的分析
- 2013長沙網路賽 E題(水題 有點小bug)
- 簡單的分享兩個下載映象的網址
- 兩道簡單的oracle題目Oracle
- 面試官:你能回答這兩個簡單的問題嗎面試
- caffe 網路結構幾個部分簡單介紹
- 成都鏈安榮登《嘶吼2022年網路安全產業圖譜》區塊鏈安全賽道榜單產業區塊鏈
- 簡單實現兩個activity相互跳轉
- 【leetcode 簡單】第二十題 合併兩個有序陣列LeetCode陣列
- 網際網路廣告的兩個變數變數
- 華為走進成都 看智簡網路如何徹底改變企業?
- 2024ccpc網路賽補題
- 成都市網際網路資訊辦公室:2018年成都市網際網路絡發展狀況
- 成都尚狐網路 ThinkPHP3.13核心PHP
- 網路 IO 模型簡單介紹模型
- 簡單理解LSTM神經網路神經網路
- 簡單網路爬蟲Ruby版爬蟲
- 利用網際網路找工作簡單麼
- 18.合併兩個有序陣列(簡單)陣列
- 【小白學PyTorch】1 搭建一個超簡單的網路PyTorch
- 3 個簡單、優秀的 Linux 網路監視器Linux
- 如何訓練一個簡單的音訊識別網路音訊
- 爬蟲學習之一個簡單的網路爬蟲爬蟲
- 社交網路不簡單:網路社交中的五“不要”
- 第三屆華中地區邀請賽網路賽題解
- 簡單介紹網路(伺服器)線路伺服器
- 2018 徐州網路賽 G 題解
- 【leetcode 簡單】 第八十五題 兩個陣列的交集 IILeetCode陣列
- 2013成都站F題||hdu4786 並查集 生成樹並查集
- 無線感測器網路簡明教程——單元習題/思考題/作業
- 最簡單的人工神經網路神經網路
- 簡單的神經網路測試神經網路
- 網路相關工具簡單彙總
- [ kvm ] 四種簡單的網路模型模型
- mrtg監控網路流量簡單配置