Luogu the first task of Luogu

From now on, I will try to share the challenges and tasks of Luogu with you. Please comment and pay more attention

Article directory


Links:
1.Luo Gu
2.Theorie des Distribu

Task 1 (difficulty: 1)

Complete this task by at least 3 questions:
P1000 super Mary game
P1001 A+B Problem
P1421 Xiaoyu buys stationery
P1425 swimming time of small fish

NO1.

Super Mary game

Difficulty: 10000000000000000000000000000000 * 0 + 1, programming ability: cout,
Title Description
Super Mary is a very classic game. Please output a scene in super Mary in the form of character drawing.

				********
               ************
               ####....#.
             #..###.....##....
             ###.......######              ###            ###
                ...........               #...#          #...#
               ##*#######                 #.#.#          #.#.#
            ####*******######             #.#.#          #.#.#
           ...#***.****.*###....          #...#          #...#
           ....**********##.....           ###            ###
           ....****    *****....
             ####        ####
           ######        ######
##############################################################
#...#......#.##...#......#.##...#......#.##------------------#
###########################################------------------#
#..#....#....##..#....#....##..#....#....#####################
##########################################    #----------#
#.....#......##.....#......##.....#......#    #----------#
##########################################    #----------#
#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#
##########################################    ############

It's more difficult than some Olympic Games. Even if you let your teacher do it, she will go back to you. The author is very hard. Let's praise it.

Code

#include<iostream>
using namespace std;
int main()
{
cout<<"                ********"<<endl;
cout<<"               ************"<<endl;
cout<<"               ####....#."<<endl;
cout<<"             #..###.....##...."<<endl;
cout<<"             ###.......######              ###            ###"<<endl;
cout<<"                ...........               #...#          #...#"<<endl;
cout<<"               ##*#######                 #.#.#          #.#.#"<<endl;
cout<<"            ####*******######             #.#.#          #.#.#"<<endl;
cout<<"           ...#***.****.*###....          #...#          #...#"<<endl;
cout<<"           ....**********##.....           ###            ###"<<endl;
cout<<"           ....****    *****...."<<endl;
cout<<"             ####        ####"<<endl;
cout<<"           ######        ######"<<endl;
cout<<"##############################################################"<<endl;
cout<<"#...#......#.##...#......#.##...#......#.##------------------#"<<endl;
cout<<"###########################################------------------#"<<endl;
cout<<"#..#....#....##..#....#....##..#....#....#####################"<<endl;
cout<<"##########################################    #----------#"<<endl;
cout<<"#.....#......##.....#......##.....#......#    #----------#"<<endl;
cout<<"##########################################    #----------#"<<endl;
cout<<"#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#"<<endl;
cout<<"##########################################    ############"<<endl;
return 0;
}

No2.

A+B Problem

Difficulty: 0, mathematics: junior one, English: sixth grade, Chinese: sixth grade
Title Description:

Input two integers a,b, and output their sum

I wonder why it typed the code below
So, the difficulty of this question is 0,
C

#include <stdio.h>

int main() {
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d", a+b);
    return 0;
}

C++

#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    cout << a+b;
    return 0;
}

Pascal

var a, b: longint;
begin
    readln(a,b);
    writeln(a+b);
end.

Python2

s = raw_input().split()
print int(s[0]) + int(s[1])

Python3

s = raw_input().split()
print int(s[0]) + int(s[1])

Java

import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[]) throws Exception {
        Scanner cin=new Scanner(System.in);
        int a = cin.nextInt(), b = cin.nextInt();
        System.out.println(a+b);
    }
}

JavaScript(JS)

const fs = require('fs')
const data = fs.readFileSync('/dev/stdin')
const result = data.toString('ascii').trim().split(' ').map(x => parseInt(x)).reduce((a, b) => a + b, 0)
console.log(result)
process.exit() // Please note that this line must be added at the exit point

Ruby

a, b = gets.split.map(&:to_i)
print a+b

php

<?php
$input = trim(file_get_contents("php://stdin"));
list($a, $b) = explode(' ', $input);
echo $a + $b;

Rust

use std::io;

fn main(){
    let mut input=String::new();
    io::stdin().read_line(&mut input).unwrap();
    let mut s=input.trim().split(' ');

    let a:i32=s.next().unwrap()
               .parse().unwrap();
    let b:i32=s.next().unwrap()
               .parse().unwrap();
    println!("{}",a+b);
}

Go

package main

import "fmt"

func main() {
    var a, b int
    fmt.Scanf("%d%d", &a, &b)
    fmt.Println(a+b)
}

C# Mono

using System;

public class APlusB{
    private static void Main(){
        string[] input = Console.ReadLine().Split(' ');
        Console.WriteLine(int.Parse(input[0]) + int.Parse(input[1]));
    }
}

Perl

my $in = <STDIN>;
chomp $in;
$in = [split /[\s,]+/, $in];
my $c = $in->[0] + $in->[1];
print "$c\n";

classical Chinese

Apply "require('fs').readFileSync" to "/ dev/stdin". It's called data.
Apply (buf = > buf. Tostring(). Trim()) to data. The "data" of the past. Now it is.
Apply (s = > s.split ('')) to data. The "data" of the past. Now it is.
Note that "There is no object operation in classical Chinese, so JavaScript syntax is required.".

One of the "data". Take one and apply "parseInt". The name is "a".
Husband "data" two. Take one and apply "parseInt". The name is "B".

Add "a" to "B". Books.

China had computers 3000 years ago, Luogu and Zhizi. I really didn't cheat you


Is this classical Chinese for fun?
Just to comment, Python is the simplest, Java is more complex, C and C + + are easy to understand, and Rust is the most troublesome (just personal point of view)

NO3

Xiaoyu buys stationery

Division is fine
(it's a serious question.)

Title Description
The head teacher gives Xiaoyu a task to buy as many pens as possible in the stationery shop. It is known that the price of a signing pen is 1 yuan and 90 Jiao, while the money the head teacher gives Xiaoyu is a yuan and b Jiao. Xiaoyu wants to know how many signing pens she can buy at most.

Input format:
The input data, in a row, includes two integers, representing a and b in turn, a < = 10000, b < = 9.

Output format:
Output an integer to indicate how many pens Xiaoyu can buy at most.

Example
input
10 3
output
5

We can know from primary mathematics that number = total amount / unit price
We can all convert them into angles for convenience
Code

#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int zongliang=a*10+b;//Total amount in angle 
	int danjia=19;//Unit price, unit: angle 
	int geshu=zongliang/danjia;//Number = total amount / unit price
	cout<<geshu;
	return 0;
} 

No.4

Swimming time of small fish

Title Description

The London Olympic Games is coming. The little fish are desperately practicing swimming to prepare for the swimming competition. The poor little fish doesn't know that the fish can't participate in the human Olympic Games. (Gou Xue)

On this day, the little fish made a precise timing for his swimming time (the timing in this question is calculated on a 24-hour basis). He found that he had been swimming from a hour and b minutes to c hour and d minutes of the day. Please help the little fish to calculate how much time did he swim on that day?

It's hard for little fish to swim. Don't miscalculate

Input format

Enter four integers in a row, representing a, B, C and D respectively.

Output format

Two integers e and F are output in one line, and the space interval is used to indicate how many hours and minutes the fish has spent in the day. Where the integer f for minutes should be less than 60.

Example of input and output
input
12 50 19 10
output
6 20
Description / tips
For all test data, it is guaranteed to be within one day, and the end time must be later than the start time.

Sample analysis:
From 12:50 to 19:10, an hour is 60 minutes, then 12h=1260=720min, 720 + 50 = 770. This is the start time of the fish
19h=1960=1140min,1140+10=1150, this is its introduction time
1150-770=380(min), it has practiced for 380min.
380/60=6... 20. It took six hours and 20 minutes to practice
Code:

#include <iostream>
using namespace std;
int main(){
	int q1,q2,j1,j2;
	cin>>q1>>q2>>j1>>j2;
	int qi=q1*60+q2,jie=j1*60+j2;
	int time=jie-qi;
	int hour=time/60,minute=time%60;
	cout<<hour<<" "<<minute;
	//Input: 12 50 19 10
	//Output 620
	/*From 12:50 to 19:10, an hour is 60 minutes, then 12h=12*60=720min, 720 + 50 = 770. This is the starting time for the fish
	19h=19*60=1140min,1140+10=1150,This is its introduction time
	1150-770=380(min),It has been practising for 380min.
	380/60=6......20,It took six hours and 20 minutes to practice*/
	
	return 0;
} 

Thank you for reading this article. Don't forget to pay attention Theorie des Distribu
Thank you.

Published 11 original articles, won praise 5, visited 227
Private letter follow

Tags: Java PHP Javascript Programming

Posted on Sun, 02 Feb 2020 22:59:23 -0800 by bjoerndalen