Submission #59916


Source Code Expand

#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <list>
#include <map>
#include <set>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>

using std::vector;
using std::list;
using std::set;
using std::map;
using std::string;
using std::stringstream;
using std::stack;
using std::queue;
using std::deque;
using std::pair;

#define TEXT(statement) std::string( #statement )

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define iterep(iter, stl) for(auto iter = stl.begin(); iter != stl.end(); ++iter)

#ifdef __DEBUG
    #define TRC(var) debug::trace(std::clog, var, TEXT(var))
    #define MSG(what) std::clog << TEXT(what) << std::endl
    #define PAUSE system("pause")
#else
	#define TRC(var)
	#define MSG(what)
	#define PAUSE
#endif //#ifdef __DEBUG

namespace util{
	template<typename _Ty> inline _Ty gcd(_Ty m, _Ty n){
		if(!m && !n) return static_cast<_Ty>(1);
		if(m < 0) m = -m;
		if(n < 0) n = -n;
		while(m && n){
			const_cast<_Ty&>(std::max(m, n)) %= std::min(m, n);
		}
		return (m ? m : n);
	}

	template<typename _Ty, typename _Al, template <typename, typename> class _Templ> inline std::string join(_Templ<_Ty, _Al> const& cont, const std::string delimitter){
		std::stringstream res;
		auto i = cont.begin();
		if(!cont.empty()){
			res << *i;
		}
		while(++i != cont.end()){
			res << delimitter << *i;
		}
		return res.str();
	}

	template<template <typename _Ty, typename _Al = std::allocator<_Ty> > class _Templ> inline _Templ<std::string> split(std::string const& str, const std::string delimitter){
		_Templ<std::string> cont;
		if(str.empty()){
			cont.push_back("");
			return cont;
		}
		std::size_t from = 0, to;
		do{
			to = str.find(delimitter, from);
			cont.push_back(str.substr(from, (to == std::string::npos ? std::string::npos : to - from)));
			from = to + delimitter.length();
		}while(to != std::string::npos);
		return cont;
	}

	inline std::string& replace(std::string& str, const std::string org, const std::string to){
		return str = join(split<std::list>(str, org), to);
	}

	inline std::string& replace(std::string& str, const char org, const char to){
		std::size_t pos = 0;
		while((pos = str.find(org, pos)) != std::string::npos) str[pos++] = to;
	}

	template<typename _Ty1, typename _Ty2> inline _Ty2& parse(_Ty1 const& from, _Ty2& to){
		std::stringstream sstr;
		sstr << from << std::flush;
		sstr >> to;
		return to;
	}
}

template<typename _Ty, typename _Al, template <typename, typename> class _Templ> inline std::ostream& operator<<(std::ostream& ostr, _Templ<_Ty, _Al> const& var){
	ostr << '{';
	ostr << util::join(var, ", ");
	ostr << '}';
	return ostr;
}

namespace debug{
	template<typename _Ty> inline void trace(std::ostream& ostr, _Ty const& var, std::string const& caption){
	#ifdef __DEBUG
		ostr << caption << ": " << var << std::endl;
	#endif //#ifdef __DEBUG
	}
}

#define CIN(var) std::cin >> var;
#define RES(res) std::cout << res << std::endl

int main(){
	int N;
	CIN(N);
	int M;
	CIN(M);

	RES(N * (N + 1) / 2 % M);

	PAUSE;
}

Submission Info

Submission Time
Task A - 団子とうさぎ
User Kt_Sz
Language C++11 (GCC 4.8.1)
Score 0
Code Size 3262 Byte
Status WA
Exec Time 20 ms
Memory 820 KB

Judge Result

Set Name All
Score / Max Score 0 / 50
Status
AC × 12
WA × 18
Set Name Test Cases
All case_000.txt, case_001.txt, case_002.txt, case_003.txt, case_004.txt, case_005.txt, case_006.txt, case_007.txt, case_008.txt, case_009.txt, case_010.txt, case_011.txt, case_012.txt, case_013.txt, case_014.txt, case_015.txt, case_016.txt, case_017.txt, case_018.txt, case_019.txt, case_020.txt, case_021.txt, case_022.txt, case_023.txt, case_024.txt, case_025.txt, case_026.txt, case_027.txt, case_028.txt, case_029.txt
Case Name Status Exec Time Memory
case_000.txt WA 20 ms 780 KB
case_001.txt WA 18 ms 788 KB
case_002.txt AC 19 ms 804 KB
case_003.txt WA 19 ms 784 KB
case_004.txt WA 19 ms 764 KB
case_005.txt AC 19 ms 796 KB
case_006.txt WA 20 ms 792 KB
case_007.txt WA 19 ms 788 KB
case_008.txt AC 19 ms 792 KB
case_009.txt AC 20 ms 664 KB
case_010.txt AC 19 ms 808 KB
case_011.txt AC 18 ms 788 KB
case_012.txt WA 20 ms 788 KB
case_013.txt WA 19 ms 788 KB
case_014.txt WA 19 ms 788 KB
case_015.txt WA 20 ms 792 KB
case_016.txt WA 19 ms 800 KB
case_017.txt AC 19 ms 796 KB
case_018.txt AC 19 ms 780 KB
case_019.txt WA 19 ms 784 KB
case_020.txt WA 20 ms 768 KB
case_021.txt WA 19 ms 792 KB
case_022.txt WA 19 ms 788 KB
case_023.txt WA 19 ms 792 KB
case_024.txt WA 19 ms 792 KB
case_025.txt AC 19 ms 820 KB
case_026.txt AC 19 ms 780 KB
case_027.txt AC 19 ms 792 KB
case_028.txt AC 19 ms 792 KB
case_029.txt WA 20 ms 792 KB