Загружаем каталог…
Загружаем каталог…
A. Lights Out time limit per test2 seconds memory limit per test256 megabytes Lenny is playing a game on a 3 × 3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off. We consider the toggling as follows: if the light was switched on then it will be switched off, if it was switched off then it will be switched on. Lenny has spent some time playing with the grid and by now he has pressed each light a certain number of times. Given the number of times each light is pressed, you have to print the current state of each light. Input The input consists of three rows. Each row contains three integers each between 0 to 100 inclusive. The j-th number in the i-th row is the number of times the j-th light of the i-th row of the grid is pressed. Output Print three lines, each containing three characters. The j-th character of the i-th line is "1" if and only if the corresponding light is switched on, otherwise it's "0". cpp #include<iostream> #include<string> #include<cctype> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s; cin >> s; int size = s.length(), cnt = 0; for (int i = 0; i < size; i++) { if (isupper(s[i])) cnt++; } if (size - cnt < cnt) { for (int i = 0; i < size; i++) { cout << (char) toupper(s[i]); } } else { for (int i = 0; i < size; i++) { cout <<(char) tolower(s[i]); } } return 0; } c# using System; using System.IO; using System.Text; using System.Threading; using System.Linq; class Program { static BufferedStream sb = new BufferedStream(Console.OpenStandardInput()); static StreamReader sr = new StreamReader(new BufferedStream(Console.OpenStandardInput()), Encoding.Default); static StreamWriter sw = new StreamWriter(new BufferedStream(Console.OpenStandardOutput()), Encoding.Default); static int ReadInt() { int c = sb.ReadByte(); while (c <= 32) { if (c == -1) return -1; c = sb.ReadByte(); } bool neg = false; if (c == '-') { neg = true; c = sb.ReadByte(); } int val = 0; while (c > 32) { val = val * 10 + (c - '0'); c = sb.ReadByte(); } return neg ? -val : val; } static void Solve() { string s = sr.ReadLine(); if (s.Count(char.IsUpper) > s.Count(char.IsLower)) { sw.Write(s.ToUpper()); } else sw.Write(s.ToLower()); sw.Flush(); } static void Main(string[] args) { Thread thread = new Thread(Solve, 1024 * 1024 * 32); thread.Start(); thread.Join(); } } python3 import sys input = sys.stdin.readline # data = sys.stdin.buffer.read() # ndata = len(data) # ii = 0 # def read_int(): # global ii, ndata, data # while ii < ndata and data[ii] <= 32: # ii += 1 # if ii >= ndata: # return 0 # sign = 1 # if data[ii] == 45: # ASCII 45 == '-' # sign = -1 # ii += 1 # num = 0 # while ii < ndata and data[ii] > 32: # num = num * 10 + (data[ii] - 48) # ii += 1 # return num * sign s=input().rstrip() upper=sum( 1 for x in s if x.isupper()) lower=sum( 1 for x in s if x.islower()) if upper>lower: print(s.upper()) else: print(s.lower()) 대충 문제가 알파벳 대문자 소문자 섞어쓰는게 짜증나서 하나로 통일하겠다는 건데 출력에서 보면 대문자가 많으면 대문자 반대면 소문자로 통일해서 춢력하는 문제로 해석됨. ᄀ
То, что RADAR обнаружил и классифицировал для этой возможности. Это опубликованный источником текст, а не подтверждение, что предложение ещё действует.
[2452일] A. Word (성공). A. Lights Out time limit per test2 seconds memory limit per test256 megabytes Lenny is playing a game on a 3 × 3 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off. We consider the toggling as follows: if the light was switched on…
Открыть источник