結果

問題 No.9002 FizzBuzz(テスト用)
ユーザー plasma_eplasma_e
提出日時 2017-02-06 14:24:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 7,855 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 97,372 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-06 17:43:20
合計ジャッジ時間 1,098 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:55:116: warning: friend declaration 'decltype(auto) utility::operator!=(const equality_comparable<T>&, const equality_comparable<T>&)' declares a non-template function [-Wnon-template-friend]
   55 |                 friend decltype(auto) operator!=(equality_comparable<T>const& lhs, equality_comparable<T>const& rhs);
      |                                                                                                                    ^
main.cpp:55:116: note: (if this is not what you intended, make sure the function template has already been declared and add '<>' after the function name here)
main.cpp:63:91: warning: friend declaration 'decltype(auto) utility::operator+(const addable<T>&, const addable<T>&)' declares a non-template function [-Wnon-template-friend]
   63 |                 friend decltype(auto) operator+(addable<T>const& lhs, addable<T>const& rhs);
      |                                                                                           ^
main.cpp:72:101: warning: friend declaration 'decltype(auto) utility::operator-(const subtractable<T>&, const subtractable<T>&)' declares a non-template function [-Wnon-template-friend]
   72 |                 friend decltype(auto) operator-(subtractable<T>const& lhs, subtractable<T>const& rhs);
      |                                                                                                     ^
main.cpp:80:101: warning: friend declaration 'decltype(auto) utility::operator*(const multipliable<T>&, const multipliable<T>&)' declares a non-template function [-Wnon-template-friend]
   80 |                 friend decltype(auto) operator*(multipliable<T>const& lhs, multipliable<T>const& rhs);
      |                                                                                                     ^
main.cpp:88:95: warning: friend declaration 'decltype(auto) utility::operator/(const dividable<T>&, const dividable<T>&)' declares a non-template function [-Wnon-template-friend]
   88 |             

ソースコード

diff #

#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>
#include<functional>
#include<numeric>
#include<limits>
#include<map>
#include<bitset>
#include<array>
#include<random>

namespace utility
{
	template<class T>struct equality_comparable;
	template<class T>struct addable;
	template<class T>struct subtractable;
	template<class T>struct multipliable;
	template<class T>struct dividable;
	template<class T>decltype(auto) operator!=(equality_comparable<T>const& lhs, equality_comparable<T>const& rhs)
	{
		return !lhs.operator==(rhs);
	}
	template<class T>decltype(auto) operator+(addable<T>const& lhs, addable<T>const& rhs)
	{
		auto x = lhs;
		x += rhs;
		return x;
	}
	template<class T>decltype(auto) operator-(subtractable<T>const& lhs, subtractable<T>const& rhs)
	{
		auto x = lhs;
		x -= rhs;
		return x;
	}
	template<class T>decltype(auto) operator*(multipliable<T>const& lhs, multipliable<T>const& rhs)
	{
		auto x = lhs;
		x *= rhs;
		return x;
	}
	template<class T>decltype(auto) operator/(dividable<T>const& lhs, dividable<T>const& rhs)
	{
		auto x = lhs;
		x /= rhs;
		return x;
	}
	template<class T>struct equality_comparable
	{
		decltype(auto) operator==(equality_comparable<T>const& rhs)const
		{
			return static_cast<T const&>(*this) == static_cast<T const&>(rhs);
		}
		friend decltype(auto) operator!=(equality_comparable<T>const& lhs, equality_comparable<T>const& rhs);
	};
	template<class T>struct addable
	{
		decltype(auto) operator+=(addable<T>const& rhs)
		{
			return static_cast<T const&>(*this) += static_cast<T const&>(rhs);
		}
		friend decltype(auto) operator+(addable<T>const& lhs, addable<T>const& rhs);
	};
	template<class T>struct subtractable
	{
		decltype(auto) operator-=(subtractable<T>const& rhs)
		{
			return static_cast<T const&>(*this) -= static_cast<T const&>(rhs);
		}

		friend decltype(auto) operator-(subtractable<T>const& lhs, subtractable<T>const& rhs);
	};
	template<class T>struct multipliable
	{
		decltype(auto) operator*=(multipliable<T>const& rhs)
		{
			return static_cast<T const&>(*this) *= static_cast<T const&>(rhs);
		}
		friend decltype(auto) operator*(multipliable<T>const& lhs, multipliable<T>const& rhs);
	};
	template<class T>struct dividable
	{
		decltype(auto) operator/=(dividable<T>const& rhs)
		{
			return static_cast<T const&>(*this) /= static_cast<T const&>(rhs);
		}
		friend decltype(auto) operator/(dividable<T>const& lhs, dividable<T>const& rhs);
	};

}
namespace math
{
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		return p == 0 ? T(1) :
			p == 1 ? val :
			p == 2 ? val*val :
			p % 2 == 0 ? pow(pow(val, p / 2), 2) :
			pow(pow(val, p / 2), 2)*val;
	}
	template<class T,class U>constexpr int ilog(T val, U base)
	{
		T v(1);
		for (int i{};;++i)
		{
			if (val <= v)
			{
				return i;
			}
			v *= base;
		}
	}

	template<std::uint64_t Mod>class mod_number:
		private utility::equality_comparable<mod_number<Mod>>,
		private utility::addable<mod_number<Mod>>,
		private utility::subtractable<mod_number<Mod>>,
		private utility::multipliable<mod_number<Mod>>,
		private utility::dividable<mod_number<Mod>>
	{
		std::uint64_t value;
	public:
		mod_number(std::uint64_t v = 0) :value(v%Mod)
		{

		}
		mod_number(int v) :value(v%Mod)
		{

		}
		mod_number(std::int64_t v) :value(v%Mod)
		{

		}
		mod_number(std::uint32_t v) :value(v%Mod)
		{

		}

		bool operator==(mod_number const& rhs)
		{
			return value == rhs.value;
		}

		auto& operator+=(mod_number const& rhs)
		{
			value += rhs.value;
			value %= Mod;
			return *this;
		}

		auto& operator-=(mod_number const& rhs)
		{
			value += Mod - rhs.value;
			value %= Mod;
			return *this;
		}

		auto& operator*=(mod_number const& rhs)
		{
			value *= rhs.value;
			value %= Mod;
			return *this;
		}

		auto& operator/=(mod_number const& rhs)
		{
			return operator*=(pow(rhs, Mod - 2));
		}
	};
}
namespace container
{
	namespace detail
	{
		template<class T, std::size_t Depth>struct tree_array
		{
			std::array<T, (1 << (Depth + 1)) - 1> ar;
			constexpr T& operator()(std::size_t index, std::size_t depth)
			{
				return ar[(1ull << depth) + index - 1];
			}
			constexpr T const& operator()(std::size_t index, std::size_t depth)const
			{
				return ar[(1ull << depth) + index - 1];
			}
		};
	}

	template<class T, std::size_t Size = 1 << 13>class addtree
	{
		std::array<T, 2 * Size - 1> data;
		T get(std::size_t left, std::size_t right, std::size_t i, std::size_t l, std::size_t r)
		{
			if (r <= left || right <= l)
				return T();
			if (left <= l&&r <= right)
			{
				return data[i];
			}
			else
			{
				return 
					get(left, right, 2 * i + 1, l, (l + r) / 2) +
					get(left, right, 2 * i + 2, (l + r) / 2, r);
			}
		}
	public:
		addtree() :data{}
		{

		}
		void change(T const& val, std::size_t index)
		{
			T from = data[index + Size - 1];
			for (std::size_t i = 1, c = math::ilog(Size, 2);i <= Size;(i <<= 1), --c)
			{
				data[i + (index >> c) - 1] -= from;
				data[i + (index >> c) - 1] += val;
			}
		}
		auto begin()const
		{
			return std::next(data.begin(), Size - 1);
		}
		auto end()const
		{
			return data.end();
		}
		T get(std::size_t left, std::size_t right)
		{
			return left > right ? T() : get(left, right + 1, 0, 0, Size);
		}
	};
	template<class T, std::size_t Depth = 13>class minmaxtree
	{
		detail::tree_array<std::pair<T, T>, Depth> data;
		T min(std::size_t left, std::size_t right, std::size_t L, std::size_t R, std::size_t depth)const
		{
			if (right <= L || R <= left)
			{
				return std::numeric_limits<T>::max();
			}
			else if (left <= L&&R <= right)
			{
				return data(L >> (Depth - depth), depth).first;
			}
			else
			{
				return std::min(
					min(left, right, L, (L + R) / 2, depth + 1),
					min(left, right, (L + R) / 2, R, depth + 1));
			}
		}
		T max(std::size_t left, std::size_t right, std::size_t L, std::size_t R, std::size_t depth)const
		{
			if (right <= L || R <= left)
			{
				return std::numeric_limits<T>::min();
			}
			else if (left <= L&&R <= right)
			{
				return data(L >> (Depth - depth), depth).second;
			}
			else
			{
				return std::max(
					max(left, right, L, (L + R) / 2, depth + 1),
					max(left, right, (L + R) / 2, R, depth + 1));
			}
		}
	public:
		void change(T const& val, std::size_t index)
		{
			data(index, Depth).first = val;
			data(index, Depth).second = val;
			for (int i = 1;i <= Depth;++i)
			{
				data(index >> i, Depth - i).first = std::min(
					data((index >> i) << 1, Depth - i + 1).first,
					data(((index >> i) << 1) + 1, Depth - i + 1).first);
				data(index >> i, Depth - i).second = std::max(
					data((index >> i) << 1, Depth - i + 1).second,
					data(((index >> i) << 1) + 1, Depth - i + 1).second);
			}
		}
		T min(std::size_t left, std::size_t right)const
		{
			return right < left ? std::numeric_limits<T>::max() : min(left, right + 1, 0, 1 << Depth, 0);
		}
		T max(std::size_t left, std::size_t right)const
		{
			return right < left ? std::numeric_limits<T>::min() : max(left, right + 1, 0, 1 << Depth, 0);
		}

		minmaxtree() :data{}
		{

		}

	};
}

void Main();
int main()
{
	std::ios::sync_with_stdio(false);
	Main();
}
//撣

void Main()
{
	int N;
	std::cin >> N;
	for (int i{};i < N;++i)
	{
		int x = i + 1;
		if (x % 15 == 0)
		{
			std::cout << "FizzBuzz" << std::endl;
		}
		else if (x % 3 == 0)
		{
			std::cout << "Fizz" << std::endl;
		}
		else if (x % 5 == 0)
		{
			std::cout << "Buzz" << std::endl;
		}
		else
		{
			std::cout << x << std::endl;
		}
	}
}
0