Codeforces Round #396(Div. 2) A. Mahmoud and Longest Uncommon Subsequence
【題意概述】
找兩個字符串的最長不公共子串。
【題目分析】
兩個字符串的最長不公共子串就應該是其中一個字符串本身,那麽判斷兩個字符串是否相等,如果相等,那麽肯定沒有公共子串,輸出“-1”.否則就是兩個字符串中長的最長的長度。
【AC】
1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() { 4 char str1[100005],str2[100005]; 5 scanf("%s%s",str1,str2); 6 if(strcmp(str1,str2) == 0 ) printf("-1\n"); 7 else printf("%d\n",max(strlen(str1),strlen(str2))); 8 return 0; 9 }
Codeforces Round #396(Div. 2) A. Mahmoud and Longest Uncommon Subsequence
相關推薦
Codeforces Round #396(Div. 2) A. Mahmoud and Longest Uncommon Subsequence
color HA \n seq 字符 turn ces DC %s 【題意概述】 找兩個字符串的最長不公共子串。 【題目分析】 兩個字符串的最長不公共子串就應該是其中一個字符串本身,那麽判斷兩個字符串是否相等,如果相等,那麽肯定沒有公共子串,輸出“-1”.否則就
Codeforces Round #417 (Div. 2) A. Sagheer and Crossroads 模擬 枚舉
ces color 一次 name exit main cst space amp Codeforces Round #417 (Div. 2) A. Sagheer and Crossroads 模擬 枚舉 題意 一個紅綠燈 按逆時針方向一次給出各個路口的左轉,
Codeforces Round #435 (Div. 2) D. Mahmoud and Ehab and the binary string[二分]
cstring stream ++ else fine eps comm 簡單的 hab 題目:http://codeforces.com/problemset/problem/862/D 題意:交互題,詢問15次以內Hamming distance,輸出一個二進制串
Codeforces Round #435 (Div. 2) E. Mahmoud and Ehab and the function(預處理+二分)
class [1] can 行處理 long 個數 分享 amp abs 題目鏈接:點我點我 題意:公式:,給出n個數,從a[1]到a[n],和m個數(b數組),然後從b數組裏挑出連續的n個數(也就m-n+1中選擇),按公式計算,使得f最小, 還有q次對a數組的操作(某
Codeforces Round #417 (Div. 2)-A. Sagheer and Crossroad
sca \n ret name nbsp style can turn ros 【題意概述】 在一個十字路口 ,給定紅綠燈的情況, 按逆時針方向一次給出各個路口的左轉,直行,右轉,以及行人車道,判斷汽車是否有可能撞到行人 【題目分析】 需要在邏輯上清晰
Codeforces Round #293 (Div. 2)A. Vitaly and Strings
這題非常有意思,各種HACk - - ,給HACK後正場比賽都。。。。。還花了大把的時間去改,還WA ,水平太差 題目連線:http://codeforces.com/contest/518/problem/A 題意:給出兩個字串s、t (t字典序比s大),問有沒有字典序在s 和t 之間的字
Codeforces Round #524 (Div. 2) A. Petya and Origami
A. Petya and Origami time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output
Codeforces Round #525 (Div. 2)A. Ehab and another construction problem
滿足 hab i++ col std other ext pro con A. Ehab and another construction problem 題目鏈接:https://codeforc.es/contest/1088/problem/A 題意: 給出一個
Codeforces Round #489 (Div. 2) ---- A. Nastya and an Array
給了我們一個數組,可以給整個陣列的元素加上一個數或者減去一個數,問多少次操作之後所有的數都變成了0 因為每次操作都是針對整個陣列的,那麼不相同的數一定不可能同時變成0,因此我們只需要對陣列去重即可,然後對於已經是0 的數,我們不需要給出操作,因此如果陣列中有0,答案減去
Codeforces Round #525 (Div. 2) A. Ehab and another construction problem
題解 題目大意 給一個n找到滿足四個條件式的a和b a和b可以相等 除了1都可以找到a=b=n這種情況滿足條件 AC程式碼 #include <stdio.h> #include <bits/stdc++.h> using namespace std;
Codeforces Round #473 (Div. 2) - D - Mahmoud and Ehab and another array construction task
題目連結 Mahmoud has an array a consisting of n integers. He asked Ehab to find another array b of the same
Codeforces Round #243 (Div. 2)——A. Sereja and Mugs
Sereja showed an interesting game to his friends. The game goes like that. Initially, there is a table with an empty cup and n water mugs on it. Then al
Codeforces Round #432 (Div. 2) D. Arpa and a list of numbers(暴力)
esp for int ans logs and codeforce style inf 枚舉質數,判斷是否超過臨界值。臨界值就是將不是因子中不含這個素數的數的個數乘以x和y的較小值,是否小於當前最小值。 #include <algorithm> #inclu
Codeforces Round #442 (Div. 2) 877E - Danil and a Part-time Job dfs序+線段樹
pac upd style init problem def ios const clas Codeforces Round #442 (Div. 2) 877E - Danil and a Part-time Job emmmm第一次見的東西感覺都好神奇 #inclu
【Codeforces Round #457 (Div. 2) A】 Jamie and Alarm Snooze
als lar clu efi out .com bit source fin 【鏈接】 我是鏈接,點我呀:) 【題意】 在這裏輸入題意 【題解】 暴力往前走x分鐘就好。 直到出現7為止。 【代碼】 #include <bits/stdc++.h&
Educational Codeforces Round #54 (Div. 2) E. Vasya and a Tree 技巧題
題目連線:http://codeforces.com/contest/1076/problem/E 本題大意: 給一棵根節點為“1”樹,給m個操作,每個操作三個整數,v,d,x,意思是從節點1,往下深度d,遍及的節點的值都加上x,d可能是0,就是隻加在自己上。結束m個操作後輸出每個節點的值。 &
Codeforces Round #525 (Div. 2) C. Ehab and a 2-operation task(數論構造)
思路來源 http://www.cnblogs.com/Dup4/p/10068891.html 題解 注意%可以起到等同於減的作用。 Solution1: 先給區間[1,n]加上一個較大的數D,比如500W, 這樣ai就變為D+ai, 由於ai-i<1
Codeforces Round #525 (Div. 2)C. Ehab and a 2-operation task
一個數 n-1 i++ 我們 text ++ target sin const C. Ehab and a 2-operation task 題目鏈接:https://codeforc.es/contest/1088/problem/C 題意: 給出n個數,然後最多可
Codeforces Round #525 (Div. 2) C. Ehab and a 2-operation task
題意: 給定一個長度為 n 的陣列a[ ],並且有兩種操作: ①將前 i 個數全都加上 x; ②將前 i 個數全都 mod x 要求用不超過 n+1 次操作,使得陣列 a[ ] 嚴格單調遞增。 思路: 對於每個數a[ i ],實施操作 a[ i ]%( a[ i ]-i
Codeforces Round #525 (Div. 2) F. Ehab and a weird weight formula
F. Ehab and a weird weight formula 題目連結:https://codeforces.com/contest/1088/problem/F 題意: 給出一顆點有權值的樹,滿足只有一個點的權值最小,然後除開這個點,每個點都有一個權值比它更小的點與之相鄰。 然後要求你重構這