結果
| 問題 |
No.46 はじめのn歩
|
| コンテスト | |
| ユーザー |
Sylvanas_ship3
|
| 提出日時 | 2017-04-03 13:13:31 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,815 bytes |
| コンパイル時間 | 699 ms |
| コンパイル使用メモリ | 68,700 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-08 03:17:33 |
| 合計ジャッジ時間 | 1,247 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#include <iostream>
#include <stdexcept>
#include <string>
#include <vector>
#include <cmath>
#define DEBUG
int getInputNumber( const std::string& );
std::vector<std::string> split( const std::string&, std::string );
int main()
{
std::cin.sync_with_stdio( false );
std::cin.tie( 0 );
// get input from stdout
std::string input;
int stride = 0, length = 0;
if ( std::getline( std::cin, input ) )
{
std::vector<std::string> argv = split( input, " " );
if ( argv.size() > 1 )
{
stride = getInputNumber(argv[0]);
length = getInputNumber(argv[1]);
}
else
{
return -1;
}
}
int ans = 0;
ans = std::ceil(static_cast<double>(length) / stride);
std::cout << ans << std::endl;
return 0;
}
int getInputNumber( const std::string& input )
{
int input_number = 0;
try
{
input_number = std::stoi( input );
}
catch ( std::invalid_argument& )
{
return 0;
}
catch ( std::out_of_range& )
{
return 0;
}
return input_number;
}
std::vector<std::string> split( const std::string& str, std::string delim )
{
std::vector<std::string> result;
result.reserve( 8 );
std::string::size_type pos = 0;
while ( pos != std::string::npos )
{
std::string::size_type current = str.find( delim, pos );
if ( current == std::string::npos )
{
result.push_back( str.substr( pos ) );
break;
}
else
{
std::string tmp = str.substr( pos, current - pos );
if ( !tmp.empty() )
{
result.push_back( tmp );
}
}
pos = current + delim.length();
}
return result;
}
Sylvanas_ship3