Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- int n = Convert.ToInt32(Console.ReadLine());
- if (n == 1)
- {
- Console.WriteLine(9);
- return;
- }
- ulong result = 9;
- for (int i = 2; i <= n; i++)
- {
- if (i % 2 == 0)
- {
- result += 9 * (ulong)Math.Pow(10, i/2 - 1);
- }
- else
- {
- result += 90 * (ulong)Math.Pow(10, (i-1)/2-1);
- }
- result = result > 10000007 ? module(result): result;
- }
- Console.WriteLine(result);
- }
- static ulong module(ulong a)
- {
- return a % ((ulong) Math.Pow(10,9)+7);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement