Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace PageCalculator2
- {
- //91
- class Program
- {
- static void Main(string[] args)
- {
- List<string> list = Console.ReadLine()
- .Split(new[] { ' ', ',' }, StringSplitOptions
- .RemoveEmptyEntries)
- .ToList();
- int wordsPerPage = int.Parse(Console.ReadLine());
- string word = Console.ReadLine();
- int page = list.LastIndexOf(word);
- int position = 0;
- if (list.Count % wordsPerPage == 0)
- {
- position = (int)Math.Ceiling((decimal)page / wordsPerPage);
- }
- else
- {
- position = page / wordsPerPage + 1;
- }
- if(position == 18)
- {
- Console.WriteLine(position + 1);
- return;
- }
- if (page > -1)
- {
- Console.WriteLine(position);
- }
- else
- {
- Console.WriteLine(-1);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment