说起来这应该是图南oj第一篇个人题解一血哦哦哦
这道题思路其实挺简单的,就是让你输出多个e,有两种方法,一种是直接循环输出良心出题人没卡到1e9
,另一种是空间换时间,把东西全存数组里之后直接输出(正解啊正解)
对于不是很熟悉系统自带api的同学可能也需要手写字符串到数字的转换功能。但是C有atoi
,C++也可以使用stringstream
转换。
以下是我能收集到的所有AC此代码的语言的题解:
Rust (作者是我)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
use std::io::stdin;
macro_rules! scan {
( $( $x:ty ),+ ) => {{
let mut string = String::new();
stdin().read_line(&mut string).unwrap();
let mut iter = string.split_whitespace();
($(iter.next().and_then(|word| word.parse::<$x>().ok()).unwrap(),)*)
}}
}
fn main() {
let a = scan!(String).0;
if a == "rabix" {
println!("push{}n","e".repeat(1e6 as usize));
} else {
println!("push{}n","e".repeat(a.parse().unwrap()));
}
}
|
C++ (作者是我)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#include <bits/stdc++.h>
using namespace std;
char* he;
int main() {
string s;
cin>>s;
int n;
if (s == "rabix") {
n = 1e6;
} else {
stringstream ssr;
ssr << s;
ssr >> n;
}
cout << "push" << string(n,'e') << "n";
}
|
Haskell (作者Rabix)
1
2
3
4
|
main = do
x <- getLine
let p a = "push" ++ replicate a 'e' ++ "n"
if head x == 'r' then putStrLn (p 1000000) else putStrLn (p (read x))
|
可怜的66pts C(这个喵喵不会调,有人帮吗)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char num[(int)1e6+1],s[(int)1e6+1];
unsigned int a;
scanf("%s",num);
if (num[0] == 'r') {
a = (int)1e6;
} else {
a = (unsigned int)atoi(num);
}
memset(s,'e',(size_t)a);
printf("push%sn",s);
}
|
Ruby (作者hyrious)
1
2
3
|
s = gets.to_i
s = 1000000 if s.zero?
print "push","e"*s,"n","\n"
|
如果有人写的C过了欢迎告知,我会及时修改